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.

Share

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.

  1. Normalize the image name so it always uses the
    gcr.io
    prefix.
  2. Validate the image format against the repo’s GCR regex guardrails.
  3. 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
    sed
    to avoid false positives in pipelines.
  • GCR is region-specific (eg.
    us.gcr.io
    ), so update the image name accordingly when targeting regional registries.

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