如何使用 cloudformation 模板在 ECR 上拉取 docker 镜像

Nan*_*ani 4 amazon-ec2 amazon-web-services amazon-cloudformation amazon-ecs

我想使用托管在 ECR 上的 docker 映像,并且我想使用 cloudformation 模板自动执行拉取操作。

我附加了具有 ECR 对 ec2 实例的完全访问权限的 IAM 角色,但它不起作用。

我正在做docker pull 1234567897.dkr.ecr.us-west-2.amazonaws.com/repo:tag,我收到错误Error response from daemon: Get https://1234567897.dkr.ecr.us-west-2.amazonaws.com/repo:tag/manifests/latest: no basic auth credentials

str*_*gjz 8

使用 ECR、EC2 和 docker,您仍然需要执行docker login.

在用户数据运行中

aws ecr get-login --no-include-email > login.sh

bash login.sh

那么你应该能够运行

docker pull ecr_registry/repo:tag

https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_AWSCLI.html