How To Push A Docker Image To Amazon ECR?
Last Updated :
23 Jul, 2025
We go over how to submit a Docker image to the Amazon Elastic Container Registry (ECR) in this tutorial. By offering a safe, scalable registry for storing and distributing Docker images inside the AWS ecosystem, Amazon ECR streamlines container management. To upload and maintain your containerized applications in Amazon ECR with ease, simply follow these instructions.
What is Docker?
Docker is a platform where it is easier to make, run, and deploy applications using containers. It simplifies the process of building, running, and deploying applications by providing a consistent environment across different platforms and infrastructure.
What is Amazon ECR?
Amazon Elastic Container Registry (ECR) is a fully managed Docker container service registry provided by Amazon Web Services (AWS). It can store, manage, and deploy container images securely. It is a reliable platform for storing and managing containerized applications.
How to push a Docker image to Amazon ECR?
Prerequisites
- Docker Hub account
- Base knowledge of Docker
- AWS account
- AWS CLI installed
- Configure AWS
- Docker CLI
Step 1: Build a Docker image
To demonstrate how to push a Docker image into ECR, we'll make a simple Docker image. Create a simple Docker image using the following link given below.
Link:- https://www.geeksforgeeks.org/devops/create-docker-image/
After creating the docker image run the image and access it through localhost.
Step 2: Creating the AWS ECR repository
Log in to the AWS console and go to the AWS ECR. Then click Get Started to create a repository.
ECR get startedIn the General settings , set the visibility settings to Private. Then set the Repository name according to your choice , Here we are naming it as " gfg-ecr " . Leave other settings as it is.
Name the ECRClick Create repository on the bottom.
Create repositoryAn empty repository now created named "gfg-ecr " .
Repository createdStep 3: Set up the image to be pushed
Here we will push a simple dokcer image of index.html that listens on port 8080. The root directory has a Dockerfile. We will use it to build an image.
The Dockerfile contains the following commands:
FROM nginx:alpine
COPY index.html /usr/share/nginx/html
EXPOSE 80
The index.html file contains:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to create docker image</title>
</head>
<body>
<H1>Hey geeks to create a docker image you have to write a Dockerfile and then build it using
docker command .
</H1>
</body>
</html>

Step 4: Build the container image and deploy locally
The container image will be built using the command below.
docker image build -t <image_name> .
The dot indicates that the Dockerfile image resides in the current directory.
After the build is finished deploy your container locally in port 8080 with the following command
docker run -d --name <container_name> -p 8080:80 <image_name>
Step 5: Push image to the Amazon ECR repository
We need to authenticate the Docker client to the registry. To proceed with the authentication, we would run a get-login-password command in the CLI to retrieve the token and then pass it to the docker login command.
(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin 046818881351.dkr.ecr.eu-north-1.amazonaws.com
After the build completes, tag your image so you can push the image to this repository:
docker tag gfg-ecr:latest 046818881351.dkr.ecr.eu-north-1.amazonaws.com/gfg-ecr:latest
Run the following command to push this image to your newly created AWS repository:
docker push 046818881351.dkr.ecr.eu-north-1.amazonaws.com/gfg-ecr:latest
Push commands in the ECR
Similar Reads
DevOps Tutorial DevOps is a combination of two words: "Development" and "Operations." Itâs a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a
7 min read
Introduction
What is DevOps ?DevOps is a modern way of working in software development in which the development team (who writes the code and builds the software) and the operations team (which sets up, runs, and manages the software) work together as a single team.Before DevOps, the development and operations teams worked sepa
10 min read
DevOps LifecycleThe DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon
10 min read
The Evolution of DevOps - 3 Major Trends for FutureDevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in
7 min read
Version Control
Continuous Integration (CI) & Continuous Deployment (CD)
Containerization
Orchestration
Infrastructure as Code (IaC)
Monitoring and Logging
Microsoft Teams vs Slack Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat
4 min read
Security in DevOps