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
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
Step 3: Push to ECR
docker push <account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repo:latest
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
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)