Menu
Amazon ECR
User Guide (API Version 2015-09-21)

Amazon ECR Registries

You can use Amazon ECR registries to host your images in a highly available and scalable architecture, allowing you to deploy containers reliably for your applications. You can use your registry to manage image repositories and Docker images. Each AWS account is provided with a single (default) Amazon ECR registry.

Registry Concepts

  • The URL for your default registry is https://aws_account_id.dkr.ecr.region.amazonaws.com.

  • By default, you have read and write access to the repositories and images you create in your default registry.

  • You must authenticate your Docker client to a registry so that you can use the docker push and docker pull commands to push and pull images to and from the repositories in that registry. For more information, see Registry Authentication.

  • Repositories can be controlled with both IAM user access policies and repository policies.

Registry Authentication

You can use the AWS Management Console, the AWS CLI, or the AWS SDKs to create and manage repositories, and to perform some actions on images, such as listing or deleting them. These clients use standard AWS authentication methods. Although technically you can use the Amazon ECR API to push and pull images, you are much more likely to use Docker CLI (or a language-specific Docker library) for these purposes.

Because the Docker CLI does not support the standard AWS authentication methods, you must authenticate your Docker client another way so that Amazon ECR knows who is requesting to push or pull an image. If you are using the Docker CLI, then use the docker login command to authenticate to an Amazon ECR registry with an authorization token that is provided by Amazon ECR and is valid for 12 hours. The GetAuthorizationToken API operation provides a base64-encoded authorization token that contains a user name (AWS) and a password that you can decode and use in a docker login command. However, a much simpler get-login command (which retrieves the token, decodes it, and converts it to a docker login command for you) is available in the AWS CLI.

To authenticate Docker to an Amazon ECR registry with get-login

Note

The get-login command is available in the AWS CLI starting with version 1.9.15; however, we recommend version 1.11.91 or later for recent versions of Docker (17.06 or later). You can check your AWS CLI version with the aws --version command.

  1. Run the aws ecr get-login command. The example below is for the default registry associated with the account making the request. To access other account registries, use the --registry-ids aws_account_id option. If you are using Docker version 17.06 or later, include the --no-include-email option after get-login. For more information, see get-login in the AWS Command Line Interface Reference.

    Copy
    aws ecr get-login

    Output:

    Copy
    docker login -u AWS -p password -e none https://aws_account_id.dkr.ecr.us-east-1.amazonaws.com

    Important

    If you receive an Unknown options: --no-include-email error, install the latest version of the AWS CLI. For more information, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide.

    The resulting output is a docker login command that you use to authenticate your Docker client to your Amazon ECR registry.

  2. Copy and paste the docker login command into a terminal to authenticate your Docker CLI to the registry. This command provides an authorization token that is valid for the specified registry for 12 hours.

    Note

    If you are using Windows PowerShell, copying and pasting long strings like this will not work. Use the following command instead. If you are using Docker version 17.06 or later, include the --no-include-email option after get-login.

    Copy
    Invoke-Expression -Command (aws ecr get-login)

    Important

    When you execute this docker login command, the command string can be visible by other users on your system in a process list (ps -e) display. Because the docker login command contains authentication credentials, there is a risk that other users on your system could view them this way and use them to gain push and pull access to your repositories. If you are not on a secure system, you should consider this risk and log in interactively by omitting the -p password option, and then entering the password when prompted.