- 我在Amazon ECR存储库中有一个名为“workshop”的图像
- 我有一个Dockerfile来获取那个图像
- CodeBuild应该从Dockerfile构建新的镜像
问题:
拉取访问被拒绝xxx.xxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop,仓库不存在或可能需要'docker login'
在我的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看起来像这样:Dockerfile looks like this:
FROM xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop:latest
CMD ["echo", "Hallo!"]
RUN code-server
可能会导致问题的原因是什么?
Allow:ecr:*
,所以我可以从ECR拉取镜像,但它没有起作用。@Marcin - vasil001ecr:*
,然后2)将服务角色添加到CodeBuild中,以允许ecr:*
用于resources: *
,并且3)在我的buildspec.yml
文件的install
阶段中添加了aws ecr get-login-password --region region | docker login -u AWS --password-stdin xxx.dkr.ecr.eu-west-2.amazonaws.com/image:tag
。 - Krizza