Install AWS ECR Credential Helper on Centos

Prerequisites
Install go and make to centos

yum install -y go make

If you are going to manage docker with another application like GitLab runner you have to apply 6,7,8th steps in gitlab-runner user

usermod -aG docker gitlab-runner
service docker restart

Installation

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login
cp /root/go/bin/docker-credential-ecr-login /usr/local/bin/

Configurations

Create folder for aws credentials if you already installed aws cli tools and setup before you can skip this step

mkdir ~/.aws/ 

Add these lines to `~/.aws/credentials`

[default]
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = SECRET_ACCESS_KEY

Add these lines to `~/.docker/config.json`

{
	"credHelpers": {
		"aws_account_id.dkr.ecr.region.amazonaws.com": "ecr-login"
	}
}

TEST

docker pull 123456789012.dkr.ecr.us-west-2.amazonaws.com/my-repository:my-tag

One Comment

Батрадин мандаринов 13 May 2021 Reply

Супер

Leave a Reply