Prerequisites:
1) Docker installed
2) Build Docker images from Dockerfile. Ref-1 Ref-2
Step 1: login to AWS and create an IAM user
Step 2: Install and configure the AWS CLI
Step 3: Create a repository ECR
Step 4: Push the Images to ECR
ECR
Amazon Elastic Container Registry (Amazon ECR) is a fully managed container registry service provided by Amazon Web Services (AWS). It enables users to store, manage, and deploy Docker container images.
Docker hub:
Docker Hub is a cloud-based registry service provided by Docker for sharing and distributing container images. It serves as a centralized repository where developers can publish and store Docker images, making it easy for others to discover, pull, and use these images.
Flow Diagram
When a user wants to store Docker images in the Amazon Elastic Container Registry (ECR), they follow a two-step process:
- Tagging of Images:
- Before pushing Docker images to ECR, it’s important to tag them. Tagging involves assigning a specific label to an image, usually in the format
registry/repository:tag
. - Tagging helps identify and manage different versions of the same image.
- Before pushing Docker images to ECR, it’s important to tag them. Tagging involves assigning a specific label to an image, usually in the format
- Pushing Docker Images to ECR:
- Once the images are tagged, the user can use the AWS CLI (Command Line Interface) or SDKs to push these images to the ECR repository.
- The AWS ECR repository is essentially a storage location in the Amazon Cloud where Docker images can be securely stored and managed.
- Pushing the images involves sending the tagged Docker images from the user’s local machine to the ECR repository in their AWS account.
- Using AWS ECR Push Commands:
- AWS provides specific commands for pushing Docker images to ECR, The user executes these commands in their terminal or command prompt on their local machine.
- These commands include authentication steps to ensure that the user has the necessary permissions to push images to the specified ECR repository.
In summary, the user follows a two-step process of tagging Docker images and then pushing them to their Amazon ECR repository using AWS CLI commands. This workflow enables them to store and manage their containerized applications in the AWS cloud environment.
Step 1: login to AWS and create an IAM user
• Login to AWS and select IAM from Services
• Create new user with the policies as shown in below snapshot
• To get credentials of the user created to be used in command prompt, please follow below step :
Select the created user >> Security Credentials >> Access keys >> Create access key >> save the csv file
Step 2: Install and configure the AWS CLI
• Open terminal and configure aws cli with required credentials from saved csv file
#aws configure
Step 3: Create repository in ECR
• Login to AWS, search for ECR in Services
• Create a Repository ecr1
Step 4: Push the Images to ECR
• Open the repository created >> view push commands and follow the push commands carefully by looking in the snapshot.
Sample commands to push image to ECR :
- To login ( Update the ecr url) :
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 976995869248.dkr.ecr.ap-south-1.amazonaws.com
- To tag local docker images to be pushed to ECR:
docker tag webapp-fe:latest 976995869248.dkr.ecr.ap-south-1.amazonaws.com/ecr1:webapp-fe
- To push to ECR :
docker push 976995869248.dkr.ecr.ap-south-1.amazonaws.com/ecr1:webapp-fe
• Check the repository for the pushed images we will be able to see images
Thanks for going through the document, please comment or contact-us in case of any queries.
Thank you for your effort to create such a great article.
Great Content!
Great article! I’m currently working on pushing Docker images to AWS ECR from my local machine, and this guide seems very helpful. Thank you.
Straightforward and easy to understand, making it simple to follow and replicate the steps without any difficulty.
Simple to follow and replicate.
Great Article!!
Thank you for this well-written and comprehensive guide on pushing Docker images from a local machine to AWS ECR! The step-by-step instructions were clear and easy to follow, and I was able to replicate the process without any issues. I especially appreciate the detailed explanations of each command and the screenshots that helped me understand the flow better. This article is a great resource for anyone working with AWS and Docker. Keep up the great work!
Great guide! The steps were clear and easy to follow. I successfully pushed my Docker images to AWS ECR thanks to your detailed instructions. Appreciate the effort!
Great article! The step-by-step guide made pushing Docker images to AWS ECR super easy to follow. I was able to replicate it smoothly. Thanks for the clear instructions!
Great content! The step-by-step instructions on pushing Docker images from a local machine to AWS ECR were very clear and easy to follow. I was able to replicate the process seamlessly and it worked perfectly. This is exactly the kind of detailed, hands-on guidance that helps simplify complex tasks. Thank you for such a well-written article!