Problem
You did set up an AWS EC2 VM, installed Docker, and set up a repository in AWS ECR (Container Registry).
You got the permissions for listing and creating credentials for use on the AWS CLI.
You finished setting up your AWS CLI to be able to log in. And you executed the Command you saw in the documentation of AWS to login docker to be able to push your image.
Proudly you tag the Docker image of your Project to match the ECR Reposity and type docker push $repository name.
The used stages in the Docker Image list in your terminal, saying waiting and then, *boom* You see the error message: “No basic auth credentials”
Solution
Requirements
AWS CLI v2
Set up AWS CLI v2 profile
Description
There is a difference in the login token being returned from the AWS CLI v2 and the expectation of the docker login command. This revolves around the protocol of the token returned and being used to login
FIx
The Amazon documentation (1) specifies to use of this command:
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
Instead, use the command (2)
$(aws ecr get-login --no-include-email | sed 's|https://||')
Result
The result is that you now are authenticated in the correct way and are now able to push your docker images to Amazon ECR (e.g. for a continuous delivery pipeline or a quick hack solution to deploy a solution)
Let me know if it helped you,
Best Frank
Sources
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html#cli-authenticate-registry
- https://stackoverflow.com/a/72255473