How To Use AWS Elastic Container Registry (ECR)

Reading Time: 2 minutes

AWS Elastic Container Registry (ECR) is a container image registry service just like the docker hub and Compare to the docker hub AWS ECR is more secure, scalable, and reliable. We can use the Docker CLI to push, pull, manage our container images as we all are familiar with docker CLI. We can create our own elastic private or public registry with ECR service. It supports resource-based permissions based using IAM so that specific EC2 instances can access repositories and images.

Prerequisites – AWS ECR

  1. Docker
  2. AWS account
  3. AWS CLI configured

NOTE: To configure AWS CLI in quick time refer to this blog How To Setup AWS CLI Tool in Ubuntu in 3 Easy Steps

Step 1: Open AWS console and navigate to ECR service

ECR dashboard

Step 2: Choose visibility type and security settings

  • Choose Private/Public visibility
    • Private: Access is managed by IAM and repository policy permissions.
    • Public: Anyone can pull or access the image
  • Name: Enter name (same as name of image)
  • Scan: Enable to scan vulnerability
  • Create repository

Step 3: Push a container image in your private repository

  • Select the repository we just created
  • Click on View Push Commands
  • Run the commands to push your container images

Commands to push/pull container image

1. Login through AWS ECR credentials in docker login

aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin
  • – -region must be your ecr region
  • – -password-stdin it must be your private ECR URL.

2. Build and tag your container image

docker build -t html-page .
docker tag html-page:latest

Must tag with your private registry name

3. Push your Container image

docker push

4. Pull your container image

docker pull

Written by 

Rahul Soni is a Software Consultant at Knoldus Software. He is always charged up for new things & learnings. He is dedicated to his work and believes in quality output. He loves to take deep dives into cloud technologies & different tools.