【问题标题】:Can't push Dockerimages to ECR无法将 Dockerimages 推送到 ECR
【发布时间】:2022-11-18 02:26:20
【问题描述】:

将我的本地 Dockerimage 推送到我的私有 ECR 时出现错误: 我的 IAM 用户拥有 AmazonEC2ContainerRegistryFullAccess 权限和我的 EC2。

$ aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin xx.dkr.ecr.eu-central-1.amazonaws.com
...    
Login Succeeded


$ aws ecr describe-repositories
{
    "repositories": [
        {
            "repositoryUri": "xx.dkr.ecr.eu-central-1.amazonaws.com/my_repo",
            "imageScanningConfiguration": {
                "scanOnPush": false
            },
            "encryptionConfiguration": {
                "encryptionType": "AES256"
            },
            "registryId": "xx",
            "imageTagMutability": "MUTABLE",
            "repositoryArn": "arn:aws:ecr:eu-central-1:xx:repository/my_repo",
            "repositoryName": "my_repo",
            "createdAt": 1650817284.0
        }
    ]
}

$ docker pull hello-world
$ docker tag hello-world:latest xx.dkr.ecr.eu-central-1.amazonaws.com/hello-world:latest
$ docker images
REPOSITORY                                                    TAG       IMAGE ID       CREATED        SIZE
xx.dkr.ecr.eu-central-1.amazonaws.com/hello-world   latest    feb5d9fea6a5   7 months ago   13.3kB
hello-world                                                   latest    feb5d9fea6a5   7 months ago   13.3kB

现在我在推送我的图像时收到错误消息:

$ docker push xx.dkr.ecr.eu-central-1.amazonaws.com/hello-world:latest
The push refers to repository [xx.dkr.ecr.eu-central-1.amazonaws.com/hello-world]
e07ee1baac5f: Retrying in 1 second
EOF

有什么建议么? 来自https://stackoverflow.com/a/70453287/10243980 的配置文件技巧不起作用。

非常感谢

【问题讨论】:

    标签: amazon-ecr


    【解决方案1】:

    我的工作示例之一如下

    aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-central-1.amazonaws.com
    docker build -t dolibarr .
    docker tag dolibarr:latest 123456789012.dkr.ecr.eu-central-1.amazonaws.com/dolibarr:latest
    docker push 123456789012.dkr.ecr.eu-central-1.amazonaws.com/dolibarr:latest
    

    与您的命令相比,它看起来非常相似。所以现在,请检查您的用户是否能够推送到存储库本身 (ecr:PutImage)。这可能是主要问题。

    寻找更多帮助的一个很好的解决方案是以下Pushing an image to ECR, getting "Retrying in ... seconds"

    我正在使用的 Docker 映像角色的策略如下(terraform 样式):

    {
      Action = [
        "ecr:BatchCheckLayerAvailability",
        "ecr:CompleteLayerUpload",
        "ecr:GetAuthorizationToken",
        "ecr:InitiateLayerUpload",
        "ecr:PutImage",
        "ecr:UploadLayerPart",
      ]
      Effect   = "Allow"
      Resource = "*"
    }
    

    尝试调整您的策略并删除“Principal”条目。这是没有必要的。

    另一个可能的原因可能与政策无关: 你使用一些本地代理吗?我在为所有公共端点(如 ECR、S3 等)使用代理服务器时遇到了一些问题。我禁用了对这些域的使用并且它有效(取决于使用 VPN 或类似的东西)。

    【讨论】:

    • 请查看我的来源:包含 ecr:Putimage
    • @Mrprimus 我在我的回答中添加了我的政策
    【解决方案2】:

    您需要创建一个名为 hello-world 的存储库。它在 Pushing a Docker image ecr 文档的开头进行了解释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 2020-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多