如何解决在 Amazon ECS 集群启动任务失败时的“映像不存在”错误?
上次更新时间:2019 年 7 月 26 日
我的 Amazon Elastic Container Service (Amazon ECS) 服务无法启动 Amazon ECS 集群中的任务。然后,我收到了一条与以下类似的错误消息:“CannotPullContainerError:守护程序响应错误:未找到 1234567890.dkr.ecr.us-east-1.amazonaws.com/test:curlnginx1234 的清单。” 如何解决此错误?
简短描述
此错误的解决方法适用于从 Amazon Elastic Container Registry (Amazon ECR) 存储库 提取映像的情形。
如果您没有收到上述错误消息,请选择基于以下任一问题或错误的解决方法:
- 由于应用程序问题或资源限制,您的容器正在退出。
- 您的 Application Load Balancer 未通过运行状况检查。
- Docker无法提取容器映像。
- [AWS service] was unable to place a task because no container instance met all of its requirements.
- [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".
注意:要排查 Amazon ECS 服务问题,请检查服务事件日志中的诊断信息。
解决方法
1. 验证您的 Amazon ECS 任务定义中声明的映像。
2. 验证 Amazon ECR 存储库中是否存在该 Docker 映像。
注意:要查看存储库信息,您可以 使用 Amazon ECR 控制台或运行以下命令:
要确认 ECR 存储库中是否存在某个映像,请运行以下 list-images 命令:
aws ecr list-images --repository-name "hello-world" --region us-east-1
要筛选 ECR 存储库中的映像,请运行以下 describe-images 命令:
aws ecr describe-images --repository-name "hello-world" --region us-east-1 --query 'sort_by(imageDetails,& imagePushedAt)[*]'
注意:请务必将命令中的相关参数更新为您的 ECR 存储库名称和 AWS 区域。
3. 当您在任务定义中指定 Amazon ECR 映像时请使用映像的完整 URI。
重要提示:验证映像的 URI 前后没有添加空格。