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, confirm 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, confirm 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 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, complete the following steps:
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?
To automatically scale your EC2 instances based on resource demand, use Amazon ECS capacity providers for EC2 workloads with managed scaling turned on. Capacity providers automatically adjust the number of EC2 instances in your Auto Scaling group to meet the resource requirements of your tasks. For more information, see Amazon ECS capacity providers for EC2 workloads and Automatically manage Amazon ECS capacity with cluster auto scaling.
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
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 the attributes registered on your container instance, run the describe-container-instances AWS CLI command:
aws ecs describe-container-instances \
--cluster CLUSTER-NAME \
--container-instances CONTAINER-INSTANCE-ID \
--region REGION
Note: Replace CLUSTER-NAME with your cluster name. Replace CONTAINER-INSTANCE-ID with your container instance ID or ARN. Replace REGION with your AWS Region.
Review the attributes array in the output and compare it against the attributes required by your task definition. Any attribute listed in the task definition but absent from the container instance output is a missing attribute.
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 attributes output shows no 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.
Note: Some task definition parameters require a specific Docker remote API version on the container instance. Others, such as the logging driver options, require the container instances to register those log drivers with the ECS_AVAILABLE_LOGGING_DRIVERS agent configuration variable. For more information, see Amazon ECS task definition parameters and Amazon ECS container agent configuration.
If Amazon ECS Exec is turned on for your tasks, the container instance might be missing the ecs.capability.execute-command attribute. This attribute is present by default on ECS-optimized Amazon Machine Images (AMIs) but might be missing on custom AMIs. To resolve this, complete one of the following actions:
Error detail: ABCDXYZ placement constraint unsatisfied
If you use placement constraints to place tasks in specific instances, then confirm that the container instances support the selected attributes or constraints.
For example, for distinctInstance, Amazon ECS places each active task 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 distinctInstance, add more container instances to your cluster.
Related information
Amazon ECS troubleshooting
Create an ECS service
Viewing Amazon ECS service event messages
Amazon ECS service event messages