An ECR repo grows to 2 TB of images. How do you control it?
IntermediateScenarioECS, EKS, Lambda and ECR
Answer
Situation read → Lifecycle policies expire old images.
What I'd do →
- Create a lifecycle policy keeping the last 20 tagged
release-*and expiring untagged after 7 days aws ecr put-lifecycle-policy --repository-name app --lifecycle-policy-text file://policy.json- Use
--image-tag-mutability IMMUTABLEfor release tags - Enable image scanning on push
Why → Storage is billed per GB-month, and old layers accumulate quietly.
Interview tip → Preview with the dry-run lifecycle preview.
More on ECS, EKS, Lambda and ECR
ECS on Fargate or on EC2: how do you choose?BeginnerDeploy a containerized API on ECS behind an ALB. What are the building blocks?BeginnerAn ECS service deployment is stuck, tasks start and stop repeatedly. How do you debug?IntermediateRoll out a new ECS service version with canary and automatic rollback.IntermediateEKS pods need access to S3 without node-level permissions. How?IntermediateUpgrade an EKS cluster from 1.31 to 1.33 safely.Intermediate