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
- Docker
- AWS account
- 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
- Open AWS console
- Naviagte to Elastic Container Registry ECR
- Create repository and Enter name of your repository

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 327645653254.dkr.ecr.ap-south-1.amazonaws.com
- – -region must be your ecr region
- – -password-stdin it must be your private ECR URL. https://aws_account_id.dkr.ecr.region.amazonaws.com.
2. Build and tag your container image
docker build -t html-page .
docker tag html-page:latest 327645653254.dkr.ecr.ap-south-1.amazonaws.com/html-page:latest
Must tag with your private registry name
3. Push your Container image
docker push 327645653254.dkr.ecr.ap-south-1.amazonaws.com/html-page:latest
4. Pull your container image
docker pull 327645653254.dkr.ecr.ap-south-1.amazonaws.com/html-page:latest