Learn to Upload a Docker Container Into Amazon Ecr

I. Introduction This blog will detail the process of uploading a docker image into Amazon ECR. Prerequisites: You must have an Am...

I. Introduction

This blog will detail the process of uploading a docker image into Amazon ECR.


  • You must have an Amazon Web Service Account

II. Creating an ECR

  1. Login to your AWS account.
  2. In the top left corner, click Service and filter the word ECR. You should see the following screen.
  3. Click the "Create a Repository" button and enter the repository named "hello-world".
  4. Click "Create Repository". We will use this repository later when we upload the docker image.
  5. Take note of the region. Eg. us-west-2.

III. Create an IAM Account that we can use to push this image

  1. Again click the Service menu and filter for "IAM". 
  2. In the IAM, click the Users menu item on the left side and create a user. What's important is the security credentials, the access and secret key that we will use to log in later (take note of these values).
  3. Make sure to add the following permissions:
    1. IAMUserChangePassword
    2. AmazonEC2ContainerRegistryFullAccess 

IV. Installing AWS CLI 2.x on Linux

Yes, we will use version 2.x and not 1.x.
  1. Follow this guide:
  2. When installing the aws cli make sure to add the --update flag.
    >sudo ./aws/install --update
So in summary here's what we need to execute:
curl "" -o ""
sudo ./aws/install

Common problem: On some machine, like Amazon Linux 2 AMI (HVM), the default aws cli version is installed (1.x). We need to update it. To do that we need to remove the existing aws and aws_completer in the /usr/local/bin folder and replace it with the newer versions.

cd /usr/local/bin
sudo rm aws aws_completer
sudo ln -s /usr/local/aws-cli/v2/2.0.7/dist/aws aws
sudo ln -s /usr/local/aws-cli/v2/2.0.7/dist/aws_completer aws_completer

V. Configuring AWS Locally

  1. Run aws_configure and enter the access and secret keys that we have created earlier. Set the region and leave the default output format. 
  2. Now we are ready to push our docker image.

VI. Creating and Build the Dockerfile

For the sake of this demo, we will just extend the hello-world image. You can create a temp directory wherever you want.
  1. Create a file Dockerfile.
  2. And input "FROM hello-world".
  3. Build Docker file by running: docker build .
  4. Don't forget . at the end of build

V. Pushing the Docker Image to AWS

  1. Open Service / ECR.
  2. Click the hello-world ecr.
  3. Hit View Push command in the top right corner. 
  4. Execute the given commands one at a time.
  5. Once done, go back to Amazon and refresh the hello-world ecr. You should arrive at the screenshot below.

VI. Common Problems


cloud-computing 5939805889222626687

Post a Comment Default Comments


Are you looking for freelancers in the Philippines? Get in touch.


If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.