How to Fix ‘no basic auth credentials’ with Docker and AWS ECR
If you are trying to push a Docker image to AWS ECR (Elastic Container Registry) and you get a no basic auth credentials
error. Then you can easily fix it as follows!
Replicating the no basic auth credentials
error
You ran something like this:
You saw something like this:
How to fix the problem
no basic auth credentials
error
Run the following AWS CLI to see if you are able to login with the system available config.
|
|
Remember to swap <region>
out with your region you are using in the docker tag
and docker push
commands. For example: eu-west-1
or us-east-1
.
At this point, you will probably get an error as follows:
|
|
Run aws configure
and enter your AWS Access Key ID
and AWS Secret Access Key
.
Once done, run the above command again, and you should not get the GetAuthorizationToken
error anymore.
Instead, it will have run a docker login -u AWS <token> <path>
command for you.
If you get the following error: unknown shorthand flag: 'e' in -e
, then run the previous command again, without the $(
and )
. So only run <meta charset="utf-8">aws ecr get-login --region <region>
It will output a set of commands for you to copy in the terminal directly. Make sure to remove the -e none
near the end, and execute the command.
Once this is done, Docker will provide a Login Succeeded
prompt.
You can now run your <meta charset="utf-8">docker push <image> <account>.dkr.ecr.<region>.amazonaws.com/<app>
command once again.
This time everything will have worked!