Infrastructure at your Service

Microsoft Team

How To Push An Image Into Amazon ECR With Docker

By March 19, 2019 Cloud No Comments

8 Steps To Push An Image Into Amazon ECR With Docker

Please bear in mind that Amazon elastic container registry (ECR) is a managed AWS Docker registry service. In this topic, we will use the Docker CLI to push an CentOS image into Amazon ECR.

1. Install Docker desktop for Windows and AWS CLI

Verify and confirm that each version has been installed properly (see below):

  • docker (dash dash)version
  • aws (dash dash)version

2. Authentication to AWS

Open Power Shell interface with administration privileges and enter the following commands:

  • aws configure
  • Access key: ****
  • Secret key: ****

The region name and output format information are not mandatory.
The data above can be found from the IAM service on AWS console management.

3. Log in to AWS elastic container registry

Use the get-login command to log in to AWS elastic container registry and save it to a text file (see below):

  • aws ecr get-login (dash dash)region eu-west-3 > text.txt

4. Authenticate Docker to AWS elastic container registry

Replace the aws account id provided into the text file saved previously and specify the password:

  • docker login -u AWS
  • Password: *****
  • Login_AWS

5. Download the CentOS image

Use the pull command to download the CentOs image:

  • docker pull centos:6.6
  • Docker_Pull_image

6. Create a repository

  • aws ecr create-repository (dash dash)repository-name centos

The repository has been created successfully into Amazon Elastic Container Registry (see below):


Before proceeding to the next step, make sure that the following requirements are met:

  • Docker version must be greater or equal to 1.7
  • The repository is created and that the user has sufficient privileges to access it
  • The Docker authentication is successful

7. List the images stored into Docker and tag them

  • docker images


  • docker tag centos:6.6 (replace the aws_account_id by your account id)

Verify that the image has been tagged:

  • docker images


8. Push the CentOS image into Amazon ECR

Use the push command to move the centos image into Amazon elastic container registry:

  • docker push (replace the aws_account_id by your account id)

From the Amazon management console, verify that the image has been pushed properly into Amazon elastic container registry (see below):


If you are in a test environment, to avoid extra costs, make sure to delete the image and the repository from Amazon elastic container registry.

Use the following command to delete the image:

  • aws ecr batch-delete-image (dash dash)repository-name centos (dash dash)image-ids imageTag=6.6

Use the following command to delete the repository:

  • aws ecr delete-repository (dash dash)repository-name centos

Need further details about Docker basics for Amazon ECR, click here.

Microsoft Team
Microsoft Team