Home > Blockchain >  Pushing a docker image to aws ecr gives no basic auth credentials
Pushing a docker image to aws ecr gives no basic auth credentials

Time:11-13

when I try to push a docker image to aws ecr it fails giving the following

sudo docker push xxxxxxx.dkr.ecr.us-east-2.amazonaws.com/my-app:1.0

7d9a9c94af8d: Preparing 
f77d412f54b5: Preparing 
629960860aca: Preparing 
f019278bad8b: Preparing 
8ca4f4055a70: Preparing 
3e207b409db3: Waiting 
no basic auth credentials

although logging in is done successfully

aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin xxxx.dkr.ecr.us-east-2.amazonaws.com

Login Succeeded

And the /home/[my user]/.docker/config.json file has the following data

{
    "auths": {
        "xxxx.dkr.ecr.us-east-2.amazonaws.com": {
            "auth": "QVsVkhaRT...."
        }
    }
}

I am using aws cli version 2.3.5

aws --version
aws-cli/2.3.5 Python/3.8.8 Linux/5.8.0-63-generic exe/x86_64.ubuntu.20 prompt/off

I am using docker version 20.10.10

docker --version 
Docker version 20.10.10, build b485636

How can I solve this problem?

CodePudding user response:

You're running sudo docker push.

This means that the credentials in your account won't be used. Instead, Docker is trying to use (nonexistent) credentials in the root user account.

Changing your command to docker push should suffice.

  • Related