amazon-ecr

How to delete untagged images from AWS ECR Container Registry

强颜欢笑 提交于 2019-12-05 00:20:57
When pushing images to Amazon ECR, if the tag already exists within the repo the old image remains within the registry but goes in an untagged state. So if i docker push image/haha:1.0.0 the second time i do this (provided that something changes) the first image gets untagged from AWS ECR . Is there a way to safely clean up all the registries from untagged images? You can delete all images in a single request, without loops: IMAGES_TO_DELETE=$( aws ecr list-images --region $ECR_REGION --repository-name $ECR_REPO --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json ) aws ecr batch