简体   繁体   中英

AWS ECR login command pipe in mac os

I am trying to login to docker & ecr in a single command in mac os.

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

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

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. Then, use the following command (replacing AWS_ACCOUNT_ID with your actual account 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 .

I was using wrong account id and the following helped me. First run:

aws sts get-caller-identity

You should get an output that looks like this:

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

And use the account id, not "john" or the "UserId"(replace your_region ):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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