Skip to content

Command Line Tools

wheels deploy prune containers

Prune old containers beyond the retention window (--keep=<n>, default 5) on every host. The current live container and everything in the retention window survives.

"
wheels deploy prune containers [--keep=<n>] [--destination=<name>] [--dry-run]
FlagDescription
--keep=<n>How many old (stopped) containers to keep per host. Default 5. There is no deploy.yml equivalent — Kamal’s retain_containers: is rejected by the config validator.
--destination=<name>Overlay destination config.
--dry-runPrint the commands without executing.

Per host, emits docker ps -a --filter label=service=<service> --filter status=exited --format '{{.ID}}' | tail -n +<keep+1> | xargs -r docker rm. Only exited containers are considered, so running containers are never removed; Docker lists newest first, so the <keep> newest exited containers survive. Older versions become unrollbackable after this — check wheels deploy app containers first if you might need them.

example
wheels deploy prune containers