Search code examples
dockeraws-cliamazon-ecr

Issues with setting up Docker authentication token with AWS ECR


I have been going over this issue for some time and cannot figure out what the issue is.

I work on Ubuntu 20.04 and have the most up to date versions of Docker and AWS CLI:

AWS CLI: aws-cli/2.1.25 Python/3.7.3 Linux/5.8.0-43-generic exe/x86_64.ubuntu.20 prompt/off

Docker: Docker version 20.10.3, build 48d30b5

Whenever I run my authentication token of this: aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com

I get this error: error during connect: Post http://docker/v1.24/auth: command [ssh -l pi -- 192.168.x.xx docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh: connect to host 192.168.x.xx port 22: No route to host

I reinstalled AWS CLI and checked my aws configure credentials. Everything is exactly as it should be. However, I still receive this error where I am thinking this is in relation to a recent raspberry pi project I did before. Would my raspberry pi project have any relation to the error I am having? I'm positive it has to be dealing with ssh access. I would appreciate any help.

Edit: I'm noticing a pattern with my SSH keys. Going to look into this area to see what I can figure out.


Solution

  • Ok, after some digging I finally found the issue. Dumb me, I forgot that I use sudo to use Docker when accessing the images and lo-and-behold all I needed to do was input sudo in the Docker pipe (since we have ECR and Docker pipes): aws ecr get-login-password --region us-east-1 | sudo docker login --username AWS --password-stdin xxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com

    I cannot believe the amount of time I invested into trying to fix this and this is all it needed! Docker has this setup by default for safety precautions. You can edit Docker to enable other users to use root privileges but this is considered a high security risk. I hope this helps out anybody with this issue. Make sure to input sudo with the Docker pipe!!!!