DevOps
Integrating Docker with AWS ECR: Build, Tag, and Push Images
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/bashREPO_URI=<account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app-repodocker build -t my-app .docker tag my-app:latest $REPO_URI:latestaws ecr get-login-password | docker login --username AWS --password-stdin $REPO_URIdocker push $REPO_URI:latest
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.
Devops
Comment