Can't push image to Amazon ECR - fails with “no basic auth credentials”

10/14 07:23
阅读数 0

问题:

I'm trying to push a docker image to an Amazon ECR registry.我正在尝试将 docker 映像推送到 Amazon ECR 注册表。 I'm using docker client Docker version 1.9.1, build a34a1d5 .我正在使用a34a1d5客户端 Docker 版本 1.9.1,构建a34a1d5 I use aws ecr get-login --region us-east-1 to get the docker login creds.我使用aws ecr get-login --region us-east-1来获取aws ecr get-login --region us-east-1 Then I successfully login with those creds as follows:然后我使用这些凭据成功登录,如下所示:

docker login -u AWS -p XXXX -e none https://####.dkr.ecr.us-east-1.amazonaws.com
WARNING: login credentials saved in /Users/ar/.docker/config.json
Login Succeeded

But when I try to push my image I get the following error:但是当我尝试推送我的图像时,我收到以下错误:

$ docker push ####.dkr.ecr.us-east-1.amazonaws.com/image:latest
The push refers to a repository [####.dkr.ecr.us-east-1.amazonaws.com/image] (len: 1)
bcff5e7e3c7c: Preparing 
Post https://####.dkr.ecr.us-east-1.amazonaws.com/v2/image/blobs/uploads/: no basic auth credentials

I made sure that the aws user had the correct permissions.我确保 aws 用户具有正确的权限。 I also made sure that the repository allowed that user to push to it.我还确保存储库允许该用户推送到它。 Just to make sure that wasn't an issue I set the registry to allow all users full access.为了确保这不是问题,我将注册表设置为允许所有用户完全访问。 Nothing changes the "no basic auth credentials" error.没有任何更改"no basic auth credentials"错误。 I don't know how to begin to debug this since all the traffic is encrypted.我不知道如何开始调试它,因为所有流量都是加密的。

UPDATE更新

So I had a bit of Homer Simpson D'Oh moment when I realized the root cause of my problem.所以当我意识到我的问题的根本原因时,我有一点 Homer Simpson D'Oh 时刻。 I have access to multiple AWS accounts.我可以访问多个 AWS 账户。 Even though I was using aws configure to set my credentials for the account where I had setup my repository the aws cli was actually using the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY .即使我使用aws configure为我设置存储库的帐户设置凭据,aws cli 实际上使用环境变量AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY So when I did aws ecr get-login it was returning a login for the wrong account.因此,当我执行aws ecr get-login它返回了错误帐户的登录信息。 I failed to notice that the account numbers were different until I just went back now to try some of the proposed answers.我没有注意到帐号不同,直到我现在回去尝试一些建议的答案。 When I remove the environment variables everything works correctly.当我删除环境变量时,一切正常。 I guess the motto of the story is if you hit this error, make sure that the repository you are logging into matches the tag you have applied to the image.我想这个故事的座右铭是,如果您遇到此错误,请确保您登录的存储库与您应用于图像的标签相匹配。


解决方案:

参考一: https://en.stackoom.com/question/2LYJB
参考二: https://stackoom.com/question/2LYJB
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部