Amazon Elastic Container Service (Amazon ECS) doesn't place my tasks on my Amazon Elastic Compute Cloud (Amazon EC2) instances as expected.
Resolution
If Amazon ECS can't place your task, then the task remains in the PROVISIONING state. You receive the following error in your service event messages:
"service ServiceName was unable to place a task because no container instance met all of its requirements."
To troubleshoot this issue, check your service event messages for this error. Then, complete the troubleshooting steps based on the error reason.
No container instances were found in your cluster
If you don't register EC2 instances to the cluster, then you receive an error. Check for scaling or instance launch issues with the capacity provider or Amazon EC2 Auto Scaling group that you configured.
If the instance launched, then check why it isn't connected to the cluster.
The closest matching (container-instance abcdexyz) has insufficient CPU/memory/GPU units available
This issue occurs when the available container instances don't have the CPU, memory, or GPU that your task requests. To resolve this issue, take the following actions:
To further troubleshoot issues with CPU, see How do I resolve "the closest matching container-instance container-instance-id has insufficient CPU units available" error in Amazon ECS?
The closest matching (container-instance abcdexyz) already uses a port required by your task
This issue occurs when the container instance already uses the required port. You can't run multiple tasks on the same port. To resolve this issue, add more container instances to your cluster. It's a best practice to automatically scale your container instances. Create a capacity provider for your cluster. Or, to allow your tasks to use any available port on a container instance, use dynamic port mapping.
The closest matching (container-instance abcdexyz) misses an attribute required by your task
This issue occurs when your container instance is missing a required attribute defined in the task definition. To check for missing attributes, run the check-attributes Amazon ECS command line interface (ECS CLI) command:
ecs-cli check-attributes --container-instances container-instance --cluster cluster-name --region region-code --task-def task-def-name
Note: Replace container-instance with your container instance name, cluster-name with your cluster name, region-code with your AWS Region, and task-def-name with your task definition.
The output of the preceding command shows a table with the missing required attributes. For information about how to troubleshoot missing attributes, see Checking for missing attributes and debugging reason attribute errors on the GitHub website.
The closest matching (container-instance abcdexyz) doesn't have the agent connected
This issue occurs when the Amazon ECS agent disconnects. To troubleshoot this issue, see the following articles:
The closest matching (container-instance abcdexyz) encountered error "MemberOf placement constraint unsatisfied."
If you use placement constraints to place tasks in specific instances, then make sure that the container instances support the selected attributes or constraints.
For more information, see How do I troubleshoot issues with Amazon ECS task placement constraints?
Related information
Amazon ECS troubleshooting