How to publish your custom Docker Images to AWS ECR

Kartheek
4 min readJul 1, 2020

--

What is a repository for Docker Image?

A Docker repository is a place where all the Docker Images can be stored. We can store multiple versions of the image in the repository. It is similar to GIT repository where it can be hosted on any repository services like Bitbucket/GITHub/CodeCommit where we can store different versions of the code/file. Any repository hosting services are called registries.

Is there any hosting repository by Docker?

Yes, docker provides its own repository hosting service called Docker Hub. If you run docker pull nginx the docker images of nginx is pulled from Docker Hub.

All the official images will have a OFFICIAL IMAGE tag.

Other Docker Registry Services

  • Amazon Elastic Container Registry (ECR)
  • RedHat Quay
  • Azure Container Registry
  • Alibaba Container Registry
  • Harbor
Today we will be using AWS ECR as our private repository to host out Docker Images.

What is AWS ECR?

As mentioned above, Amazon Elastic Container Registry is another flavor of Docker Container Registry Service for storing, managing and deploying docker container images.

Note: In AWS ECR, you can have only have one repository per image but each repository can have multiple versions of a single image.

Dependencies

Let’s get started…

You need to build the application image that would be tagged and pushed to AWS ECR.

To build the image checkout the link below…

Publishing the Docker Image to AWS ECR

Login to AWS Console, and got to AWS ECR service…

Then click Get Started to create a repository…

Now you will be redirected to a page where you can name the repository. The first section of the repo name will be the domain of the registry and the second part after / will be our actual repo name movie-app-image in this case.

After clicking create repository we will be redirected to the Repositories dashboard page where you can find all the created repositories…

Once the repository is created we need to authenticate your Docker client to your registry, tag the image and publish. AWS provided the required push commands to view the push commands select your repo name and click View Push Commands to get the required push commands for the repository.

Step 1: Get Authenticated Client

Run the following command to get the authenticated client…

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <Your_Registry_Namespace>

Step 2: Build Docker Image

Run the following command to build your application image…

docker build -t <your_app_image_name>:1.0 .

Step 3: Tag your Image with AWS Registry domain

Run the following command to tag your application image…

docker tag <your_app_image_name>:1.0 736305949852.dkr.ecr.us-east-1.amazonaws.com/<your_app_repo_name>:1.0

Step 4: Publish Image to AWS ECR

Run the following command to publish your image…

docker push 736305949852.dkr.ecr.us-east-1.amazonaws.com/<your_app_repo_name>:1.0

Success

--

--

Kartheek

Cloud platform engineer @Lenovo previously @Citrix