问题:
对 xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop 的拉取访问被拒绝,存储库不存在或可能需要“docker 登录”
在我的 buildspec 文件中,我尝试使用 docker 登录,但没有任何变化。
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin
xxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com
- CODEBUILD_RESOLVED_SOURCE_VERSION="${CODEBUILD_RESOLVED_SOURCE_VERSION:-$IMAGE_TAG}"
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
Dockerfile 看起来像这样:
FROM xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop:latest
CMD ["echo", "Hallo!"]
RUN code-server
什么可能导致问题?
尝试更新您的 aws-cli 并使用最新版本,因为
get-login
已被弃用。
新命令是这样的:
aws ecr get-login-password \
--region <region> \
| docker login \
--username AWS \
--password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com
@vasil001
喜欢这里描述:https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policies.html
如果设置 IAM 策略,您必须指定 ECR 存储库或存储库的完整 arn(带有区域代码和帐户 ID)。