Amazon ECR
Amazon ECR private and public container registries, IAM access, image scanning, tags, lifecycle policies and replication.
What it is
Amazon ECR (Elastic Container Registry) stores and manages Docker (container) images on AWS.
- Private repositories, and public ones published in the Amazon ECR Public Gallery (gallery.ecr.aws).
- Fully integrated with ECS (and EKS), and backed by Amazon S3, so images are stored durably.
- Access is controlled through IAM. If ECS can't pull an image, check the IAM policy of the instance profile or task execution role (
ecr:GetAuthorizationToken,ecr:BatchGetImage…). - Supports:
- image vulnerability scanning: basic scanning for operating system CVEs, on push or manually; enhanced scanning with Amazon Inspector for OS and programming-language packages, continuously;
- versioning with image tags (and immutable tags, so a tag can't be overwritten);
- lifecycle policies that delete old or untagged images automatically;
- replication to other Regions and accounts;
- pull through cache, which keeps copies of public images (such as from Docker Hub) in the private registry.
Real-world examples
- A CI pipeline builds an image on every merge and pushes it to ECR with the commit hash as tag; ECS deploys that tag.
- A security team turns on enhanced scanning and gets an EventBridge alert when a new CVE affects a running image.
- A team keeps only the last 20 images per repository with a lifecycle policy, to control storage costs.
Exam tips
- "Private Docker registry on AWS" → Amazon ECR.
- "ECS tasks can't pull the image" → IAM permissions (instance profile or task execution role).
- "Scan container images for vulnerabilities" → ECR image scanning (enhanced = Amazon Inspector).
- "Delete old images automatically" → ECR lifecycle policy.
- "Images available in another Region for DR" → ECR cross-Region replication.
Common traps
- "ECR images are public by default." Private repositories are private; access is through IAM.
- "ECR scanning needs a third-party tool." Basic scanning is built in; enhanced uses Amazon Inspector.
Hands-on lab: push an image to ECR
Goal: create a private repository and push an image from CloudShell.
Costs money
ECR storage costs $0.10 per GB-month; a small image for a day costs far less than a cent. Any Region works.
Create a repository
ECR → Private registry → Repositories → Create repository. Name saa-hello, turn on Scan on push. Create.
Push an image
Open the repository and choose View push commands. In CloudShell (which has Docker), run them, using a public image instead of building one:
aws ecr get-login-password | docker login --username AWS --password-stdin <account>.dkr.ecr.<region>.amazonaws.com
docker pull public.ecr.aws/docker/library/hello-world:latest
docker tag public.ecr.aws/docker/library/hello-world:latest <account>.dkr.ecr.<region>.amazonaws.com/saa-hello:v1
docker push <account>.dkr.ecr.<region>.amazonaws.com/saa-hello:v1Look at the result
Refresh the repository: image tag v1 appears, and after a moment its scan status shows the findings (probably none for this tiny image).
Expected result: your own private copy of an image, scanned on push.
Clean up: delete the saa-hello repository (choose to delete its images too).
AWS documentation
ECS scaling and patterns
ECS Service Auto Scaling, scaling the EC2 capacity underneath with Auto Scaling groups and capacity providers, and event-driven ECS patterns with EventBridge and SQS.
Amazon EKS
Amazon EKS as managed Kubernetes, how a cluster is laid out, node types including EKS Auto Mode, storage with CSI drivers, and running containers on premises with ECS Anywhere, EKS Anywhere and EKS Distro.