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.
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
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With