How do I resolve the "[AWS service] was unable to place a task because no container instance met all of its requirements" error in Amazon ECS?
"I want to place a task in Amazon Elastic Container Service (Amazon ECS). However, I receive the following error: "[AWS service] was unable to place a task because no container instance met all of its requirements.""
"I want to place a task in Amazon Elastic Container Service (Amazon ECS). However, I receive the following error: "[AWS service] was unable to place a task because no container instance met all of its requirements."Short descriptionYou can receive this error due to one or more of the following reasons:No container instances were found in your clusterThe port needed by the task is already in useNot enough memory for your tasksNot enough CPU units for your container instanceNot enough available elastic network interface attachment pointsA required attribute is missing for your container instanceFor more information on these issues, see Service event messages.Note: If you didn't receive the preceding error message, then choose an article based on one of the following error messages that you received:[AWS service] was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id has insufficient CPU units available.[AWS service] was unable to place a task because no container instance met all of its requirements. The closest matching container-instance container-instance-id encountered error "AGENT".ResolutionNote: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.To resolve the error, choose a resolution based on your use case:If there are no container instances registered in your cluster, then add container instances to your cluster.If the port required by the task is in use, then add container instances to your cluster, or reduce your number of desired tasks.Note: If possible, consider using dynamic port mapping to allow your tasks to use any available port on a container instance.If the container instance doesn't have enough memory for your tasks, then reduce the amount of memory in your task definition. Or, launch more container instances in your cluster. For more information, see the Not enough memory section in Service event messages. This section is located under: service (service-name) was unable to place a task because no container instance met all of its requirements.If the container instance doesn't have enough CPU units, then adjust the CPU required by the tasks, or launch more container instances in your cluster.For more information, see the Not enough CPU section in Service event messages. This section is located under service (service-name) was unable to place a task because no container instance met all of its requirements. Or, refer to How do I resolve "the closest matching container-instance container-instance-id has insufficient CPU units available" error in Amazon ECS?If the container instance doesn't have any available elastic network interface attachment points, then add more container instances to your cluster. For more information, see the Not enough available ENI attachment points section in Service event messages. This section is located under service (service-name) was unable to place a task because no container instance met all of its requirements. If the issue persists, consider using awsvpcTrunking to increase elastic network interface density on your Amazon Elastic Compute Cloud (Amazon EC2) instances.If the container instance is missing a required attribute, then refer to the Container instance missing required attribute section in Service event messages. This section is located under service (service-name) was unable to place a task because no container instance met all of its requirements. To find the missing attributes, run the ecs-cli check-attributes command:ecs-cli check-attributes --task-def Task_Definition --container-instances Container_Instance --cluster Cluster_NameNote: For Task_Definition Name, enter the name of your task definition. For Container_Instance, enter the name of your container instance. For Cluster_Name, enter the name of your cluster.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. Be sure that the subnets for your service and the container instance match. To do this, recreate the Amazon ECS service in the subnet where the container instance exists. For more information, see Task definition parameters and Amazon ECS container agent configuration.For example, if you run the following command:ecs-cli check-attributes --task-def task:1 --container-instances 650cf1df296749e1bce1b9e0cebb588a --cluster test-clusterThe output looks similar to:Container Instance  Missing Attributestes-cluster         NoneFor more information, run the command:ecs-cli --helpRelated informationAmazon ECS task networkingService throttle logicFollow"