DEV Community

Cover image for Day 6: Integrating Docker with AWS ECR: Build, Tag, and Push Images
Pragnesh Patel
Pragnesh Patel

Posted on

Day 6: Integrating Docker with AWS ECR: Build, Tag, and Push Images

From Day 5, we have an ECR repo. Today, build on Day 3's app: build, tag, and push to ECR.

Step 1: Authenticate Docker to ECR

Get login command:

aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-west-2.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Step 2: Build and Tag the Image

In my-app dir:

docker build -t my-app .
docker tag my-app:latest <account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repo:latest
Enter fullscreen mode Exit fullscreen mode

Step 3: Push to ECR

docker push <account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repo:latest
Enter fullscreen mode Exit fullscreen mode

Verify in ECR console.

Troubleshooting: Check IAM permissions (AmazonEC2ContainerRegistryFullAccess).

Automation Tip

Use a script:

#!/bin/bash
REPO_URI=<account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repo
docker build -t my-app .
docker tag my-app:latest $REPO_URI:latest
aws ecr get-login-password | docker login --username AWS --password-stdin $REPO_URI
docker push $REPO_URI:latest
Enter fullscreen mode Exit fullscreen mode

Today’s Takeaway

Your image is in the cloud! Ready for ECS.

What’s Next?
In Day 7, we’ll explore ECS fundamentals.

Top comments (0)