🚀 Push Your Python Docker Image to AWS ECR (Elastic Container Registry)
In this tutorial, you’ll learn how to upload your Python Docker image to AWS Elastic Container Registry (ECR) —
a fully managed Docker image repository by Amazon Web Services.
This is the final step before deploying your app to EC2, ECS, or any cloud service. 🌍
🪜 Step 1: Install AWS CLI
First, ensure you have the AWS CLI installed in your Ubuntu/WSL terminal.
sudo apt update
sudo apt install awscli -y
Once installed, verify it:
aws --version
🪜 Step 2: Configure AWS CLI
Now configure your AWS account credentials:
aws configure
When prompted, enter:
AWS Access Key ID [None]: YOUR_ACCESS_KEY
AWS Secret Access Key [None]: YOUR_SECRET_KEY
Default region name [None]: ap-south-1
Default output format [None]: json
🔑 You can find your Access Key ID and Secret Key
under IAM → Users → Security Credentials in your AWS Console.
🪜 Step 3: Create a Repository in AWS ECR
Go to your AWS Management Console → Elastic Container Registry → Repositories.
- Click on Create Repository.
- Repository name:
python-hello - Visibility: Private
- Region:
ap-south-1 - Click Create.
After creation, copy your ECR URI — it looks like:
807650717461.dkr.ecr.ap-south-1.amazonaws.com/python-hello
🪜 Step 4: Authenticate Docker with AWS ECR
Run this command to log Docker into ECR:
aws ecr get-login-password --region ap-south-1 | \
docker login --username AWS --password-stdin 807650717461.dkr.ecr.ap-south-1.amazonaws.com
✅ You should see:
Login Succeeded
🪜 Step 5: Tag Your Local Docker Image
Now tag your existing image (from the previous post) with the ECR repo name:
docker tag python-hello:latest 807650717461.dkr.ecr.ap-south-1.amazonaws.com/python-hello:latest
🪜 Step 6: Push Your Image to AWS ECR
Now push it to the ECR repository:
docker push 807650717461.dkr.ecr.ap-south-1.amazonaws.com/python-hello:latest
It will take a few moments to upload depending on your internet speed.
Once complete, you’ll see your image in the AWS Console under your repository.
🪜 Step 7: Verify in AWS Console
- Open AWS Console → Elastic Container Registry → Repositories
- Click on
python-hello - You’ll see your image tagged as
latest
🎉 That’s it! Your Docker image is now securely stored in AWS ECR.
🧩 Step 8 (Optional): Run Image from ECR
If you want to test the pulled image:
docker pull 807650717461.dkr.ecr.ap-south-1.amazonaws.com/python-hello:latest
docker run -d -p 8000:8000 807650717461.dkr.ecr.ap-south-1.amazonaws.com/python-hello:latest
Now visit:
👉 http://localhost:8000
You’ll again see: Hello World from Docker + Python!
🎯 Summary
You’ve now learned how to build, tag, and push a Docker image to AWS ECR.
This is a crucial step before deploying your app on AWS ECS or EC2.
In the next post, we’ll cover Deploying your ECR image to AWS ECS (Elastic Container Service).
📚 Next Learning Path
- ✅ Install Docker inside WSL
- ✅ Build & Run Python Apps with Docker
- ✅ Push Docker Image to AWS ECR (You’re here!)
- 🚀 Deploy Docker Container to AWS ECS
