我正在尝试将docker映像推送到Amazon ECR注册表。我使用docker客户端docker版本1.9.1,构建a34a1d5。我使用aws ecr get-login -region us-east-1来获得docker登录信用。然后我成功登录这些学分如下:

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

但当我试图推动我的图像,我得到以下错误:

$ 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

我确保aws用户具有正确的权限。我还确保存储库允许用户推送到它。为了确保这不是一个问题,我将注册表设置为允许所有用户完全访问。没有什么可以改变“no basic auth credentials”错误。我不知道如何开始调试,因为所有的流量都是加密的。

更新

So I had a bit of Homer Simpson D'Oh moment when I realized the root cause of my problem. I have access to multiple AWS accounts. 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. So when I did aws ecr get-login it was returning a login for the wrong account. 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.


当前回答

这只是为了防止有人像我一样从来没有读过F手册 我遵循了上面建议的所有步骤,比如

aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.eu-west-1.amazonaws.com

而且总是没有基本的认证证书 我创建了一个名为

123456789.dkr.ecr.eu-west-1.amazonaws.com/my.registry.com/namespace 

并试图推广一个叫alpine:latest的图片

123456789.dkr.ecr.eu-west-1.amazonaws.com/my.registry.com/namespace/alpine:latest
2c6e8b76de: Preparing
9d4cb0c1e9: Preparing
1ca55f6ab4: Preparing
b6fd41c05e: Waiting
ad44a79b33: Waiting
2ce3c1888d: Waiting
no basic auth credentials   

愚蠢的错误在我的代表,因为我必须创建一个注册表在ecr使用完整的容器路径。 我使用完整的容器路径创建了一个新的注册中心,而不是在名称空间上结束

123456789.dkr.ecr.eu-west-1.amazonaws.com/my.registry.com/namespace/alpine

又低又快

123456789.dkr.ecr.eu-west-1.amazonaws.com/my.registry.com/namespace/alpine:latest 
The push refers to repository [123456789.dkr.ecr.eu-west-1.amazonaws.com/my.registry.com/namespace/alpine]
0c8667b5b: Pushed
730460948: Pushed
1.0: digest: sha256:e1f814f3818efea45267ebfb4918088a26a18c size: 7

工作很好

其他回答

我在OSX上运行时也遇到了这个问题。我看到了Oliver Salzburg的响应,并检查了我的~/.docker/config.json。它里面有来自我拥有的不同AWS帐户的多个授权凭证。我删除了该文件,再次运行get-login后,它工作了。

有一个非常简单的方法可以将docker镜像推送到ECR: Amazon ECR docker Credential Helper。只需根据提供的指南安装它,更新您的~/.docker/config。Json格式如下:

{
    "credsStore": "ecr-login"
}

你将能够推/拉你的图像没有docker登录。

Make sure you have created the ECR registry first. Then as per the ECR Push Command Instructions, cut and paste the following commands Execute the docker login command (eval on Mac/Linux skips the cut-and-paste) eval $(aws ecr get-login --region us-east-1) add --profile if you use multiple AWS Accounts eval $(aws ecr get-login --region us-east-1 --profile your-profile) docker build -t image-name . docker tag image-name:latest ############.dkr.ecr.us-east-1.amazonaws.com/image-name:latest docker push ############.dkr.ecr.us-east-1.amazonaws.com/image-name:latest

如果出现错误,请确保再次运行所有命令!使用aws ecr get-login获得的凭据是临时的,将会过期。

我的问题是拥有多个AWS证书;因为我试图部署到开发,这是有效的:

$(aws ecr get-login --no-include-email --region eu-west-1 --profile dev | sed 's|https://||')

我也经历过同样的问题。

生成新的AWS凭据(访问密钥)并使用新的凭据重新配置AWS CLI解决了这个问题。

之前,aws ecr get-login——region us-east-1生成的docker登录命令带有无效的EC注册中心URL。