I want to deploy a task in Amazon Elastic Container Service (Amazon ECS), but I get the following error: "[AWS service] was unable to place a task because no container instance met all of its requirements."
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
If your container instance is missing a requirement, then Amazon ECS can't deploy tasks. To resolve the no container instance met all of its requirements error, check the error details, and then complete the relevant troubleshooting steps.
Error detail: No registered container instances in the cluster
This issue occurs when there are no container instances in your cluster. To resolve this issue, add container instances to your cluster. Also, make sure that your container instances aren't failing to register to the Amazon ECS cluster.
Error detail: Closest matching container-instance encountered error "AGENT"
You receive this error when the Amazon ECS container agent that runs on the container instance that's designated for task placement is disconnected. To resolve this error, see How do I resolve the error "the closest matching container-instance container-instance-id encountered error 'AGENT'" for my service in Amazon ECS?
Error detail: Closest matching container instance is already using a port required by your task
You receive this error when a port that the container instance needs is already being used in the instance. You can't run multiple tasks on the same port. To resolve this issue, add more instance containers to your cluster. Or, to allow your tasks to use any available port on a container instance, use dynamic port mapping.
Error detail: Closest matching container instance has insufficient memory, CPU, or GPU units available
If you receive an insufficient memory, insufficient GPU, or insufficient CPU error, then check the resources that each task and container instance uses. To resolve this issue, take the following actions:
For information about insufficient CPU, see How do I resolve "the closest matching container-instance container-instance-id has insufficient CPU units available" error in Amazon ECS?
Use dynamic scaling for your Amazon ECS container instances to automatically add more instances to the cluster based on CPU or memory resource usage. Monitor the CpuUtilized and MemoryUtilized Amazon CloudWatch metrics to identify a threshold for your system. Then, use target tracking step scaling, or step and simple scaling policies to scale your Auto Scaling group based on that threshold. For more information about how to monitor your resource usage, see Container monitoring.
Error detail: Unable to place task resource eni or Instance Network interface limit exceeded
If the container instance has no available elastic network interface attachment points, then reduce the number of tasks and task replicas. Or, add more container instances to your cluster. If the issue persists, then use awsvpcTrunking to increase elastic network interface density on your Amazon Elastic Compute Cloud (Amazon EC2) instances.
Error detail: Closest matching container instance missing attribute required by your task
Note: To install ecs-cli, see amazon-ecs-cli on the GitHub website.
You receive this error when your task definition contains a parameter that requires a container instance attribute that's missing on your container instance.
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 this command shows a table with required attributes that are missing.
You can configure an Amazon ECS service to run on a subnet that's different from the subnet for the container instance. In this case, the output of the ecs-cli-check-attributes command shows None for missing attributes, even though the task fails with the missing attribute error. The subnets for your service and the container instance must match. To resolve this issue, recreate the Amazon ECS service in the subnet where the container instance exists. For more information, see Amazon ECS task definition parameters.
Error detail: ABCDXYZ 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 example, for distinctinstance, each active task is placed on a different container instance. If there are 5 tasks and 3 container instances available, then task placement fails and you receive the constraint unsatisfied error. To resolve this issue for dinstinctinstance, add more container instances to your cluster.
Related information
Amazon ECS troubleshooting
Create an ECS service
How do I troubleshoot Amazon ECS tasks that stop or fail to start when my container exits?
Viewing Amazon ECS service event messages