AWS › Elastic Container Registry (ECR)
How do ECR lifecycle policies help automatically manage and clean up old or unused container images to control storage costs?
IntermediateAnswer
ECR lifecycle policies let you define rules that automatically expire and delete older container images based on criteria such as image age or the total number of images to retain, which is important since container repositories can otherwise accumulate a large number of old, unused images from every single build over time, unnecessarily increasing storage costs if left completely unmanaged.
aws ecr put-lifecycle-policy --repository-name my-app --lifecycle-policy-text file://lifecycle-policy.jsonReal-world example A development team configures a lifecycle policy on their ECR repository that automatically deletes any untagged image older than fourteen days, preventing years worth of intermediate build artifacts from silently accumulating unnecessary storage costs.