The Amazon ECR Docker Credential Helper is a credential helper for the Docker daemon that makes it easier to use Amazon Elastic Container Registry.
You must have at least Docker 1.11 installed on your system.
You also must have AWS credentials available. See the AWS credentials section for details on how to use different AWS credentials.
You can install the Amazon ECR Credential Helper from the docker
or ecs
extras.
$ sudo amazon-linux-extras enable docker
$ sudo yum install amazon-ecr-credential-helper
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
A community-maintained Homebrew formula is available in the core tap.
$ brew install docker-credential-helper-ecr
On macOS, another community-maintained installation method is to use MacPorts.
$ sudo port install docker-credential-helper-ecr
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
You can install the Amazon ECR Credential Helper from the Debian Buster archives. This package will also be included in future releases of Debian.
$ sudo apt update
$ sudo apt install amazon-ecr-credential-helper
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
You can install the Amazon ECR Credential Helper from the Ubuntu 19.04 Disco Dingo (and newer) archives.
$ sudo apt update
$ sudo apt install amazon-ecr-credential-helper
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
A community-maintained package is available in the Arch User Repository.
$ git clone https://aur.archlinux.org/amazon-ecr-credential-helper.git
$ cd amazon-ecr-credential-helper
$ makepkg -si
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
To build and install the Amazon ECR Docker Credential Helper, we suggest Go
1.15 or later, git
and make
installed on your system.
If you just installed Go, make sure you also have added it to your PATH or Environment Vars (Windows). For example:
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
Or in Windows:
setx GOPATH %USERPROFILE%\go
<your existing PATH definitions>;%USERPROFILE%\go\bin
If you haven't defined the PATH, the command below will fail silently, and
running docker-credential-ecr-login
will output: command not found
You can install this via the go
command line tool.
For go version 1.16 and newer run :
go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@latest
or with an older version of go run :
go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login
If you already have Docker environment, just clone this repository anywhere
and run make docker
. This command builds the binary with Go inside the Docker
container and output it to local directory.
With TARGET_GOOS
environment variable, you can also cross compile the binary.
Once you have installed the credential helper, see the Configuration section for instructions on how to configure Docker to work with the helper.
Place the docker-credential-ecr-login
binary on your PATH
and set the
contents of your ~/.docker/config.json
file to be:
{
"credsStore": "ecr-login"
}
This configures the Docker daemon to use the credential helper for all Amazon ECR registries.
With Docker 1.13.0 or greater, you can configure Docker to use different
credential helpers for different registries. To use this credential helper for
a specific ECR registry, create a credHelpers
section with the URI of your
ECR registry:
{
"credHelpers": {
"public.ecr.aws": "ecr-login",
"<aws_account_id>.dkr.ecr.<region>.amazonaws.com": "ecr-login"
}
}
This is useful if you use docker
to operate on registries that use different
authentication credentials.
The Amazon ECR Docker Credential Helper allows you to use AWS credentials stored in different locations. Standard ones include:
- The shared credentials file (
~/.aws/credentials
) - The
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environment variables - An IAM role for an Amazon ECS task
- An IAM role for Amazon EC2
To use credentials associated with a different named profile in the shared credentials file (~/.aws/credentials
), you
may set the AWS_PROFILE
environment variable.
The Amazon ECR Docker Credential Helper reads and supports some configuration options specified in the AWS
shared configuration file (~/.aws/config
). To disable these options, you must set the AWS_SDK_LOAD_CONFIG
environment
variable to false
. The supported options include:
- Assumed roles specified with
role_arn
andsource_profile
- External credential processes specified with
credential_process
- Web Identities like IAM Roles for Service Accounts in
Kubernetes (Note: Kubernetes
users using containers with a non-root user may encounter permission issues described in this
bug and may need to employ a workaround adjusting the
Kubernetes
securityContext
.)
The Amazon ECR Docker Credential Helper uses the same credentials as the AWS CLI and the AWS SDKs. For more information about configuring AWS credentials, see Configuration and Credential Files in the AWS Command Line Interface User Guide.
The credentials must have a policy applied that allows access to Amazon ECR.
Environment Variable | Sample Value | Description |
---|---|---|
AWS_ECR_DISABLE_CACHE | true | Disables the local file auth cache if set to a non-empty value |
AWS_ECR_CACHE_DIR | ~/.ecr | Specifies the local file auth cache directory location |
docker pull 123456789012.dkr.ecr.us-west-2.amazonaws.com/my-repository:my-tag
docker push 123456789012.dkr.ecr.us-west-2.amazonaws.com/my-repository:my-tag
docker pull public.ecr.aws/amazonlinux/amazonlinux:latest
If you have configured additional profiles for use with the AWS CLI, you can use
those profiles by specifying the AWS_PROFILE
environment variable when invoking docker
.
For example:
AWS_PROFILE=myprofile docker pull 123456789012.dkr.ecr.us-west-2.amazonaws.com/my-repository:my-tag
There is no need to use docker login
or docker logout
.
Logs from the Amazon ECR Docker Credential Helper are stored in ~/.ecr/log
.
For more information about Amazon ECR, see the the Amazon Elastic Container Registry User Guide.
If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the instructions here or email AWS security directly.
The Amazon ECR Docker Credential Helper is licensed under the Apache 2.0 License.