In this short tutorial we will see how we can push a Docker Image to a private or public registry in ECR.
Step 1: Create an AWS ECR Repository
A Private Repository: It will be managed and accessed by IAM and Registry Policy Permissions and not be accessible by everyone.
OR
A public Repository: It will be accessible by everyone.
Created Repository
Private ECR Repo:
Public ECR Repo:
Step 2: Prepare Docker Image to be pushed to ECR
I have taken an example of a simple Nodejs application got from the internet and created an image on Docker Desktop using following command from the directory where DOCKERFILE for my app is present.
Tag the image before pushing to ECR
For Private ECR Repo
For Public ECR Repo
Step 3: Authenticate Docker to AWS ECR
You will need AWS credentials configured and required IAM permissions to that AWS user.
For Private ECR Repo:
For Public ECR Repo:
Step 4: Push Image to ECR
For Private ECR Repo:
For Public ECR Repo:
Image pushed to Private ECR Repo
Image pushed to Public ECR Repo
And the image is ready to be used in a container started in an ECS or EKS cluster.