I have a microsoft/iis
task set on a ECS cluster running on AMI optimized windows 2016 server.
The task starts fine (it shows RUNNING), but after a few hours, it just stops with: Essential container in task exited
.
Looking at the EC2 instance, I can see the container running, but it does not show the regular logs I expect on this particular container.
Another curious thing is that if I manually do a docker run <my image>
on the EC2, it starts the container and the log is populated.
Any idea what could be wrong?
EDIT
adding task definition (JSON format)
{
"ipcMode": null,
"executionRoleArn": null,
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": null,
"entryPoint": [
"powershell",
"-Command"
],
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 80
}
],
"command": [
"New-Item -Path C:\\inetpub\\wwwroot\\index.html -ItemType file -Value '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p>' -Force ; C:\\ServiceMonitor.exe w3svc"
],
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "microsoft/iis",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "windows_sample_app"
}
],
"placementConstraints": [],
"memory": "1024",
"taskRoleArn": null,
"compatibilities": [
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:<my-region>:<my-id>:task-definition/windows-simple-iis:1",
"family": "windows-simple-iis",
"requiresAttributes": [],
"pidMode": null,
"requiresCompatibilities": [],
"networkMode": null,
"cpu": "512",
"revision": 1,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
For a windows task CPU shares should not be zero. "cpu": 0.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
On Windows container instances, the CPU limit is enforced as an absolute limit, or a quota. Windows containers only have access to the specified amount of CPU that is described in the task definition. Updating the CPU shares should get everything running and logs to populate.