docker - Amazon ECR 的拉取访问被拒绝,存储库不存在或可能需要 'docker login'

标签 docker dockerfile aws-cloudformation aws-codebuild amazon-ecr

  1. 我在 Amazon ECR 存储库中有一个名为 Workshop 的图像
  2. 我有一个 Dockerfile 来提取该镜像
  3. CodeBuild 应从 Dockerfile 构建新镜像

问题:

pull access denied for xxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/workshop, repository does not exist or may require '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 看起来像这样:

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

引用文献:

关于docker - Amazon ECR 的拉取访问被拒绝,存储库不存在或可能需要 'docker login',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65831129/

相关文章:

docker - 如何与Docker一起 “start over”?

python - Docker无法连接到Flask

docker - Visual Studio 2017 Docker - 更改多阶段构建的目标

docker - 在 Dockerfile 中运行 sqlcmd

amazon-web-services - 无法创建可公开访问的数据库实例,因为客户 VPC 没有 - AWS

amazon-web-services - 云形成 : extraneous key [DependsOn] is not permitted

docker - 来自 Dockerfile 的 git@gitlab.com : Permission denied - fatal: Could not read from remote repository,

postgresql - docker构建错误: psql: could not connect to server: Connection refused

python - 在 amazon/aws-cli docker 镜像上安装 python 3.9

amazon-web-services - 是否可以从 Chef AWS/Opsworks 说明书运行 Ansible 剧本?