Delete untagged images on Google Cloud Registry

gcloud container images list-tags gcr.io/project-id/repository --format=json --limit=unlimited will give you an easily consumable json blob of info for images in a repo (such as digests w/ associated tags).

In order to just enumerate all digests which lack tags:

gcloud container images list-tags gcr.io/project-id/repository --filter='-tags:*' --format='get(digest)' --limit=unlimited

Which you can iterate over and delete with: gcloud container images delete --quiet gcr.io/project-id/repository@DIGEST


Handy when you glue them together with awk and xargs

gcloud container images list-tags gcr.io/${PROJECT_ID}/${IMAGE} --filter='-tags:*' --format='get(digest)' --limit=unlimited | awk '{print "gcr.io/${PROJECT_ID}/${IMAGE}@" $1}' | xargs gcloud container images delete --quiet