Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't push image to Amazon ECR - fails with "no basic auth credentials"

People also ask

How do I push a docker image to AWS ECR repository?

To push a Docker image to an Amazon ECR repositoryAuthenticate your Docker client to the Amazon ECR registry to which you intend to push your image. Authentication tokens must be obtained for each registry used, and the tokens are valid for 12 hours. For more information, see Private registry authentication.

How do I authenticate with Amazon ECR?

To authenticate Docker to an Amazon ECR registry with get-login-password, run the aws ecr get-login-password command. When passing the authentication token to the docker login command, use the value AWS for the username and specify the Amazon ECR registry URI you want to authenticate to.


if you run $(aws ecr get-login --region us-east-1) it will be all done for you

Update July 2021:

get-login is now deprecated in version 1 of the AWS CLI. If you're using version 2 of the AWS CLI, you must use get-login-password.

You can pipe the output of get-login-password to your docker login command to authenticate docker to your ECR registry:

aws ecr get-login-password | docker login --username AWS --password-stdin ####.dkr.ecr.us-east-1.amazonaws.com

Now you should be able to docker push and have it go straight to your ECR registry.


In my case this was a bug with Docker for Windows and their support for the Windows Credential Manager.

Open your ~/.docker/config.json and remove the "credsStore": "wincred" entry.

This will cause credentials to be written to the config.json directly. You'll have to log in again afterwards.

You can track this bug through the tickets #22910 and #24968 on GitHub.


If you use profiles, don't forget to pass --profile=XXX to aws ecr get-login.


Update

Since AWS CLI version 2 - aws ecr get-login is deprecated and the correct method is aws ecr get-login-password.

Therefore the correct and updated answer is the following: docker login -u AWS -p $(aws ecr get-login-password --region us-east-1) xxxxxxxx.dkr.ecr.us-east-1.amazonaws.com