Part 10: Container Registries: Managing Images and Tags in GCR
AuthorEmmanuel Secretaria
Published Aug 17, 2025
Explore how to enumerate container images and tags to support release auditing and rollbacks.
Scope inspiration:
gcr_list_tags.sh, gcr_newest_image_tags.sh, gcr_tags_timestamps.sh.
This series follows the repo’s GCP inventory flow so every step builds a repeatable, audit-friendly picture of your environment. Part 10 narrows in on container images so you can validate releases and retention policies.
What this script does (walkthrough)
The GCR tag helpers are designed to list tags cleanly for automated consumption.
- Normalize the image name so it always uses the
prefix.gcr.io - Validate the image format against the repo’s GCR regex guardrails.
- List tags for the image and emit one tag per line for easy piping.
Operational caveats and gotchas
- If an image doesn’t exist in GCR, gcloud returns no output and no error, so treat empty output carefully.
- The script filters blank lines with
to avoid false positives in pipelines.sed - GCR is region-specific (eg.
), so update the image name accordingly when targeting regional registries.us.gcr.io
Example command usage
# List all tags for an image in the default gcr.io registry gcp/gcr_list_tags.sh my-project/my-image
# Explicitly specify the registry prefix gcp/gcr_list_tags.sh gcr.io/my-project/my-image