Not able to login into Docker through AWS CLI

161 Views Asked by At

I am trying to push one docker image to my AWS ECR, but i am getting this error during login

Command I used:

aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/xxxxxx



Error

failed to get console mode for stdin: The handle is invalid.
Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `The stub received bad data.
2

There are 2 best solutions below

0
Mark B On

Split the piped command up into it's separate commands:

First run aws ecr-public get-login-password --region us-east-1 and see the password it outputs.

Then run the second command, but pass it the password as an argument: docker login --username AWS --password <password-output-from-previous-command> public.ecr.aws/xxxxxx

This will help you isolate the error you are encountering, and possibly get completely past it.


If you can, I highly recommend using AWS ECR Credentials Helper instead.

2
deep bajaj On

Your command seems to be correct, However can you help me understand which OS are you using second what is the AWS CLI version that you are using in order to isolate the issue.

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

Here is the official help whitepaper - https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html