Skip to content

imglife cleanup

imglife cleanup [flags]

Applies the retention policy to all images in build.images and their corresponding mirrors. Deletes (or archives) tags that exceed keep_last or max_age_days.

FlagDefaultDescription
--dry-runfalseSimulate deletions without making any changes
--listfalsePrint affected tags and exit
Terminal window
# Preview: show what would be deleted
imglife cleanup --list
# Dry-run: simulate without deleting
imglife cleanup --dry-run
# Apply the retention policy
imglife cleanup

A tag is a deletion candidate if it satisfies either condition:

  1. Its position in the sorted tag list exceeds keep_last.
  2. Its creation timestamp is older than max_age_days days.

Tags listed in retention.exclude_tags are never deleted.

When retention.archive.enabled: true, tags are copied to retention.archive.registry before deletion. This creates a safety net for accidentally deleted images.

After retention.archive.keep_days days, the archived copy is deleted on the next cleanup run.

imglife reports images that exist in the OCI registry but are no longer declared in build.images. These “type-orphan” images appear in the --list output with a warning but are not automatically deleted. Remove them manually after verification.

retention:
keep_last: 5
max_age_days: 90
exclude_tags: [latest, stable]
archive:
enabled: true
registry: registry.example.com/archive
keep_days: 180

See retention configuration for the full reference.

After each run (not in --list mode), imglife prints a summary to stdout:

Cleanup Summary · 3.8s
───────────────────────────────────
Tags examined 24
├─ Deleted 5
├─ Archived 2
├─ Kept 17
└─ Errors 0

In --dry-run mode the header is prefixed with [dry-run]. Set NO_COLOR=1 or TERM=dumb to disable ANSI colors.

CodeMeaning
0Cleanup completed (including partial deletions)
1Fatal error preventing cleanup