How to push Docker images into AWS ECR

How to push Docker images into AWS ECR

Amazon ECR stands for Elastic Container Registry, and the Docker registry service of AWS manages it. It is more scalable, reliable, and secure. Developers can manage images (e.g., push and pull) by using the Docker CLI. Docker images in task definitions are used by Amazon ECS to launch containers on Amazon EC2 instances in your clusters.

Introduction

Docker is a container or a software platform that allows you to build, test, and deploy distributed applications. Docker Container can be explained as a running instance of an image, and Docker Images can be created by including commands and instructions line by line in a text file, which is called Dockerfile.

Docker Images are used to create Docker containers. Images contained the application files, configuration files, or multiple images e.g Ubuntu, and the Dockerfile as well.

Dockerfile consists of many commands which will get execute step by step in its separate or temporary container and the container will get automatically removed as the command will get executed.
There will be a main Container in which all the sub-containers will get created and deleted automatically.

In this tutorial, we will push the Docker image into the AWS ECR registry.

Prerequisites

  • A Docker image
  • AWS login credentials
  • AWS ECR registry
  • Need permissions to IAM role to access ECR

Steps to push the image:

  • Step-1: AWS Authentication
  • Step-2: Get Docker images
  • Step-3: Tagging
  • Step-4: Push the image into ECR

AWS Authentication

You must log in to AWS ECR from Docker client. To authenticate an Amazon ECR registry to Docker with get-login-password, run the command: “aws ecr get-login-password”.

Note: “Specify the AWS username and registry URI when passing the auth token to the command for docker login.”

Command to authenticate with AWS ECR registry:

aws ecr get-login-password --region us-west-1 | docker login --username zehntech --password-stdin aws_account_id.dkr.ecr.us-west-1.amazonaws.com


Get Docker Images

To get the list of docker images, run below command in your Docker CLI tool:

dokcer images

This will list all the docker images created in your docker environment.

Copy the Docker Image ID which you want to push into the AWS ECR registry.
You can get an image with the “repository:tag” value or with the image ID in the output of the above command.


Tagging

You can assign your metadata to each repository in the form of tags. It helps you to manage your Amazon ECR repositories.

Tag your image with the Amazon ECR registry.
Note: “The name of the repository should be the same as the name of your image.

Command to tag the image:

docker tag e6ge4d780n39 aws_account_id.dkr.ecr.region.amazonaws.com/zehntech-app

here, e6ge4d780n39 is the tag of the image, and zehntech-app is the id of the image.


Push the image into ECR

Command to Push the image into ECR:

docker push aws_account_id.dkr.ecr.region.amazonaws.com/zehntech-app

You can review the Amazon ECR registry for the confirmation. The image should be visible there.

Note: You can apply multiple tags per image in AWS ECR. The default maximum value is 100 tags.

Summary

In this tutorial, we have authenticated to the Amazon ECR registry from Docker CLI using the “aws ecr get-login-password” command then get tagged the Docker image and pushed the image into the ECR registry.

Related post

LMS

7 Ways for Ensuring Your LMS Implementation to be a Success

E-learning solutions are not just any other trend in the marketplace today. With the need for better and more accessible learning and the importance of skill development for professional growth, e-learning industry has created its separate niche in this dynamic and ever-changing business environment.

Read More »
RPA and WLA

How to Integrate Workload Automation & RPA to Create Dynamic Synergies?

Automation is at its core in today’s dynamic, fast-growing, and ever-changing business world. As you talk about the discipline, you can come across topics and types of automation such as workload automation, IT process automation, business process automation, run book automation, batch processing, robotic process automation… and these are just to name a few.

Read More »