Skip to main content

Google Container Registry Cleanup utility

Project description

Google Container Registry Cleanup utility

If you use a CI system to push images to Google Container Registry you will eventually run into a situation where you're paying more than you would like for the storage there.

This tool helps you keep those costs reasonable, while allowing you to benefit from caches, keeping backups for rollbacks, etc.

Prerequisites and setup

  • Python 3.9+
  • Gcloud SDK with an authentication token that has admin access to the registry properly configured
pip install -U gcrc


Replace with the specific GCR address to your repository, e.g. if your Google Cloud project is called foo-bar and it's in the EU zone this would likely be

List all images

Figures out the different images we can access in the Container Registry.

gcrc list-images

Show information on images

Analyzes current images and any need for cleanup based on current configuration without actually deleting anything. Use to check that configuration seems correct.

gcrc image-info

Clean up images

Look up images with unneeded tags and delete them from Google Container Registry

gcrc cleanup


The following environment variables can be used to adjust the configuration:


Keeps at least this many tags for every image.


Keep everything from within this many days.

KEEP_EXTRA='["^latest$", "^(master|main)-"]'

List of regex matches for important images that we want to keep an extra KEEP_TAGS_MIN items of. Formatted as a JSON list of strings.

The default is to keep latest and any tags starting with master- or main- for people who tag their images like <branch>-<timestamp or commit hash or uuid>.

You can also put these in a .env -file, but environment variables take priority over .env.

# .env
KEEP_EXTRA='["^important-", "^latest$"]'

Financial support

This project has been made possible thanks to Cocreators and Lietu. You can help us continue our open source work by supporting us on Buy me a coffee.

"Buy Me A Coffee"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcrc-1.0.5.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

gcrc-1.0.5-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page