awslabs / amazon-ecr-credential-helper

Automatically gets credentials for Amazon ECR on docker push/docker pull

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No basic auth credentials

sourcehawk opened this issue · comments

On a new ubuntu server (22.04.1) machine with a fresh install of docker there is no .docker folder located at home directory and therefore also no config.json file. After following the instructions and creating those folders/files manually I get an error response from daemon. Is the credential helper just not being used at all or what exactly is happening?

Here is the setup procedure I followed.

  1. Install docker

$ sudo apt install docker.io

  1. Install the cred helper build (0.5.0-1build1)

$ sudo apt install amazon-ecr-credential-helper

  1. Locate the binary

$ sudo dpkg -L amazon-ecr-credential-helper
/usr/bin/docker-credential-ecr-login

  1. Add the binary to ~/.bashrc

echo '/usr/bin/docker-credential-ecr-login' >> ~/.bashrc

  1. Create ~/.docker because it doesn't exist

mkdir ~/.docker

  1. Create config.json file with required content

touch ~/.docker/config.json
Add the contents

  1. Export credentials with admin access to ecr

export AWS_ACCESS_KEY_ID=FOOBAR
export AWS_SECRET_ACCESS_KEY=BARFOO

  1. Try to pull docker image from aws ecr repository

sudo docker pull numbers.dkr.ecr.eu-west-1.amazonaws.com/my-repo:1.0.0

  1. I get an error from docker daemon

Error response from daemon: Head "https://numbers.dkr.ecr.eu-west-1.amazonaws.com/v2/my-repo/manifests/1.0.0": no basic auth credentials

I found the solution

I had to enable the command docker to be executed without sudo for docker to get the config file from the ubuntu user's home directory. The command in question is sudo usermod -aG docker $USER followed by restarting the current session.