DEV Community

Chinmay Tonape
Chinmay Tonape

Posted on

8

How to push Docker Image to Public and Private AWS ECR Repository

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.

Private ECR Repository

OR

A public Repository: It will be accessible by everyone.

Public ECR Repository

Created Repository
Private ECR Repo:
Private ECR Repo
Public 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.



docker image build -t simple-nodejs-app.


Enter fullscreen mode Exit fullscreen mode

Tag the image before pushing to ECR
For Private ECR Repo



docker tag simple-nodejs-app:latest 197317184204.dkr.ecr.us-east-1.amazonaws.com/simple-nodejs-app:latest


Enter fullscreen mode Exit fullscreen mode

For Public ECR Repo



docker tag simple-nodejs-app:latest public.ecr.aws/n4o6g6h8/simple-nodejs-app:latest


Enter fullscreen mode Exit fullscreen mode

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:



aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 197317184204.dkr.ecr.us-east-1.amazonaws.com


Enter fullscreen mode Exit fullscreen mode

For Public ECR Repo:



aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/n4o6g6h8


Enter fullscreen mode Exit fullscreen mode

Step 4: Push Image to ECR

For Private ECR Repo:



docker push 197317184204.dkr.ecr.us-east-1.amazonaws.com/simple-nodejs-app:latest


Enter fullscreen mode Exit fullscreen mode

For Public ECR Repo:



docker push public.ecr.aws/n4o6g6h8/simple-nodejs-app:latest


Enter fullscreen mode Exit fullscreen mode

Image pushed to Private ECR Repo
Image in Private Repo

Image pushed to Public ECR Repo
Image ins Public Repo

Screenshot
Sample Image Push

And the image is ready to be used in a container started in an ECS or EKS cluster.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more