简体   繁体   English

mac os 中的 AWS ECR 登录命令 pipe

[英]AWS ECR login command pipe in mac os

I am trying to login to docker & ecr in a single command in mac os.我正在尝试在 mac os 中的单个命令中登录 docker & ecr。

So far I got till this:到目前为止,我得到了这个:

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

Error response from daemon: login attempt to https://xxx.dkr.ecr.ap-south-1.amazonaws.com/v2/ failed with status: 400 Bad Request来自守护进程的错误响应:登录尝试https://xxx.dkr.ecr.ap-south-1.amazonaws.com/v2/失败,状态:400 错误请求

Any idea how to solve this?知道如何解决这个问题吗?

aws ecr get-login --region ap-south-1 

has the response, am trying to pipe that to next command有响应,正在尝试将 pipe 发送到下一个命令

docker login -u AWS -p **KEY** https://xx.dkr.ecr.ap-south-1.amazonaws.com

First, make sure that you're upgrading your AWS CLI to the latest version.首先,确保您将 AWS CLI 升级到最新版本。 Then, use the following command (replacing AWS_ACCOUNT_ID with your actual account ID):然后,使用以下命令(将AWS_ACCOUNT_ID替换为您的实际账户 ID):

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

See also the ECR docs .另请参阅ECR 文档

I was using wrong account id and the following helped me.我使用了错误的帐户 ID,以下帮助了我。 First run:第一次运行:

aws sts get-caller-identity

You should get an output that looks like this:您应该得到一个 output,如下所示:

{
    "UserId": "AIDAUQ6COKW7R5SO7XYZ",
    "Account": "311256041234",
    "Arn": "arn:aws:iam::311256041234:user/john" 
}

And use the account id, not "john" or the "UserId"(replace your_region ):并使用帐户 ID,而不是“john”或“UserId”(替换your_region ):

aws ecr get-login-password --region your_region | docker login --username AWS --password-stdin 311256041234.dkr.ecr.your_region.amazonaws.com

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

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