简体   繁体   English

即使登录 docker 并成功,也无法将图像推送到 ECR

[英]can't push image to ECR even though login in docker and was successfully

When attempting to push image to ECR, I always get 'no basic auth' error.尝试将图像推送到 ECR 时,我总是收到“无基本身份验证”错误。 ECR is in us-east-1. ECR 位于 us-east-1。

This is login command这是登录命令

aws ecr get-login --region us-east-1 --no-include-email

I get response like this我得到这样的回应

docker login -u AWS -p eyJwYXl ... 

I copy this response and run command, than I got this response我复制此响应并运行命令,然后收到此响应

Login Succeeded

I assume that I logged in AWS and docker successfully, so I try to push image to ECR我假设我成功登录 AWS 和 docker,所以我尝试将图像推送到 ECR

docker push AWSID.dkr.ecr.us-east-1.amazonaws.com/repositoryname

Than response is like this比响应是这样的

ed9f73170eb1: Preparing
f26c0d1885c7: Preparing
254cc70ba305: Preparing
6bfcbc08ecad: Preparing
0cb1addb8efc: Preparing
f9109426e338: Waiting
b7f99d06d826: Waiting
24d803cb9c1a: Waiting
25c4f6422338: Preparing
69b416623121: Waiting
0753f0746a0d: Waiting
a20143cd0986: Waiting
3028f693c3e6: Waiting
514a0f74b55d: Waiting
no basic auth credentials

To figure out what causes error, I checked ~/.docker/config.json .为了找出导致错误的原因,我检查了~/.docker/config.json my config.json is like this.我的 config.json 是这样的。

{
"auths": {
    "AWSPATH.dkr.ecr.us-east-1.amazonaws.com": {
        "auth": "QVd..},
    "https://index.docker.io/v1/": {}
       },
"HttpHeaders": {
    "User-Agent": "Docker-Client/19.03.5 (darwin)"
}

It seems to be an Authentication issue.这似乎是一个身份验证问题。 Reconfigure your AWS-CLI, maybe that will resolve your issue.重新配置您的 AWS-CLI,也许可以解决您的问题。

aws configure

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

尝试以这种方式登录并推送:

eval $(aws ecr get-login --no-include-email | sed 's|https://||')

The problem was, jenkins server already had aws configured with different team's account.问题是,jenkins 服务器已经使用不同团队的帐户配置了 aws。 so I added region settings (we uses different region) and the problem solved.所以我添加了区域设置(我们使用了不同的区域)并解决了问题。

For me, it was simply missing permissions.对我来说,这只是缺少权限。

There are a number of permissions related to uploading such as有许多与上传相关的权限,例如

                "ecr:UploadLayerPart",
                "ecr:InitiateLayerUpload",
                "ecr:CompleteLayerUpload"
                "ecr:PutImage"

I have solved it by adding them to my agent's allowed permissions.我通过将它们添加到我的代理允许的权限中解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM