我正在尝试将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.


当前回答

我也有同样的问题。请按照以下步骤-

aws configure (configure with your credentials) If you have created the ECR repository, in console you can find a button with "view push commands". You get three commands there and will be able to push. Else, here are below three commands. aws ecr get-login-password --region | docker login --username AWS --password-stdin .dkr.ecr.us-west-2.amazonaws.com build your docker image - docker build -t . docker tag :latest .dkr.ecr.us-west-2.amazonaws.com/:latest docker push .dkr.ecr.us-west-2.amazonaws.com/:latest

请注意-在。dkr.ecr.us-west-2.amazonaws.com中,该区域将是您的默认区域。对我来说是我们-西方-2,所以是一样的。

希望这节省了你的时间。

其他回答

AWS放弃了get-login,请使用以下命令

aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <ecr-repo-full-path>

例子

aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 607348619222.dkr.ecr.ap-south-1.amazonaws.com

如果这对谁有帮助的话……

我的问题是,我必须使用——profile选项,以便使用来自凭证文件的正确配置文件进行身份验证。

接下来,我忽略了——region [region_name]命令,这也给出了“no basic auth credentials”错误。

我的解决方案是改变我的命令:

Aws ecr get-login

:

Aws——profile [profile_name] ecr get-login——region [region_name]

例子:

Aws—配置文件foo ecr get-login—区域us-east-1

希望这能帮助到别人!

在我的情况下,这是一个错误与Docker的Windows和他们的支持Windows凭证管理器。

打开~/.docker/config。并删除"credsStore": "wincred"条目。

这将导致凭证被写入配置。直接json。之后你需要重新登录。

你可以通过GitHub上的#22910和#24968票来跟踪这个bug。

执行该命令后:

(aws ecr get-login -no-include-email -region us-west-2)

只需从输出中运行docker登录命令

docker login -u AWS -p epJ....

docker登录ECR的方式是什么

我也遇到过同样的问题,用这个命令解决了它。我可以用,请按照你的账号更新 这是为Ubuntu机器,其中AWS-CLI需要安装Docker

algorithm_name='multi-model-xgboost'

account=$(aws sts get-caller-identity --query Account --output text)

# Get the region defined in the current configuration
region=$(aws configure get region)

aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}