canasta image prune

From Canasta Wiki

canasta > image > prune

canasta image prune

Reclaim container image storage on a host

Synopsis

Remove container images the host no longer needs, and their orphaned layers. Upgrades leave superseded Canasta images behind, and repeated pushes of the same tag (e.g. the :local tags used by --build-from, build: sidecars, and image push) orphan the previous push's layers. Nothing else ever collects them, so the disk only grows until this runs.

On a Docker or Podman host, removes the Canasta image tags no instance registered on the host is pinned to, and the --build-from images (canasta:local-<id>) of instances no longer registered, and the CanastaBase image they were built on (canasta-base:local) once no registered instance's --build-from image remains and no Kubernetes instance is on the host, then prunes dangling layers. A host carrying both runtimes is reclaimed in each. On a Kubernetes host, prunes containerd images no pod references, then runs the in-cluster registry's garbage collector (with --delete-untagged) and restarts the registry so its in-memory blob cache matches the pruned store. A host running both is reclaimed on both paths.

The Docker build cache, and on a Kubernetes host the Docker copies of images built for the in-cluster registry, are kept because they speed up the next build; their size or names are reported with the command that removes them (docker builder prune, docker image rm).

Volumes are never touched, and an image an instance on the host is pinned to is kept whether or not that instance is running.

Avoid pushing images while the prune runs — a push racing the registry garbage collector can be corrupted (a limitation of the registry itself).

canasta image prune [flags]

Examples

canasta image prune
canasta image prune --dry-run
canasta image prune -H prod1

Flags

Flag Shorthand Description Default Required Orchestrator
--dry-run Report what would be removed without removing anything Both
--host -H Target host (a saved host name or user@hostname; default: localhost) Both

Global flags

Flag Shorthand Description Default Required Orchestrator
--help -h Show help message and exit Both
--verbose -v Enable verbose output Both