LinuxCommandLibrary

gcrane-gc

Garbage collect unused container images in registry

TLDR

List untagged images

$ gcrane gc [repository]
copy

Whether to recurse through repositories
$ gcrane gc [repository] [[-r|--recursive]]
copy

Display help
$ gcrane gc [[-h|--help]]
copy

SYNOPSIS

gcrane gc [--dry-run] [--quiet] [--parallelism=N] repository

PARAMETERS

--dry-run
    Simulate deletion; print layers that would be removed without action

--quiet
    Suppress all non-error output

--parallelism=N
    Number of parallel workers (default: 10)

DESCRIPTION

gcrane-gc (or gcrane gc) is a subcommand of the gcrane tool for managing Google Container Registry (GCR) repositories. It performs garbage collection by identifying and deleting container image layers that are no longer referenced by any manifests, thereby reclaiming storage space.

This command is essential for repository maintenance, as Docker layers can accumulate over time from deleted tags or images, leading to wasted quota. It scans the specified repository, computes layer references via manifests, and removes dangling blobs.

Usage requires Google Cloud authentication via gcloud auth. It operates only on gcr.io repositories and supports dry-run mode for safe testing. Parallelism can be tuned for large repos. Note that gcrane is deprecated in favor of modern tools like crane and Artifact Registry.

CAVEATS

Requires gcloud auth login; deprecated tool—migrate to Artifact Registry; deletes layers irreversibly outside dry-run; limited to gcr.io repos.

AUTHENTICATION

Run gcloud auth configure-docker and gcloud auth login first.

EXAMPLE

gcrane gc --dry-run gcr.io/my-project/my-repo
Tests deletion of unreferenced layers.

HISTORY

Introduced by Google ~2017 for GCR management; deprecated post-2021 with Artifact Registry launch, urging migration to crane.

SEE ALSO

crane(1), gcloud(1), docker(1)

Copied to clipboard