Skip to content

retention

The retention section controls what imglife cleanup deletes.

retention:
keep_last: 5
max_age_days: 90
exclude_tags:
- latest
- stable
archive:
enabled: true
registry: registry.example.com/archive
keep_days: 180
FieldTypeRequiredDefaultDescription
keep_lastintegerno5Number of most-recent tags to keep per image
max_age_daysintegerno30Maximum age in days; older tags are deleted
exclude_tags[]stringno[]Tags to never delete (exact match)
archive.enabledboolnofalseMove expired tags to an archive registry before deletion
archive.registrystringif archiveRegistry path for archived images
archive.keep_daysintegerno90Days to retain archived tags before final deletion

For each configured image, imglife cleanup:

  1. Fetches the full tag list from the OCI registry.
  2. Sorts tags by creation date (newest first).
  3. Excludes any tags matching exclude_tags.
  4. Keeps the keep_last most recent tags.
  5. Deletes (or archives) tags older than max_age_days.

Both conditions apply: a tag must violate either the keep_last limit or the max_age_days limit to be a deletion candidate. A tag at position 6 that was created 10 days ago is deleted because keep_last=5; a tag from 120 days ago is deleted regardless of position.

When archive.enabled: true, imglife copies the tag to the archive registry before deleting it from the source:

registry.example.com/bases/alpine:3.19.4-core1.0.0
→ copy → registry.example.com/archive/bases/alpine:3.19.4-core1.0.0
→ delete from source

After archive.keep_days days, subsequent cleanup runs delete the archived tag too.

imglife also detects type-orphan images: images that exist in the registry but are no longer declared in the build: section. These are reported in the --list output but not automatically deleted — manual confirmation is required.

Always preview before applying:

Terminal window
imglife cleanup --list # show what would be affected
imglife cleanup --dry-run # simulate without deleting
imglife cleanup # apply