Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Podman Difficulty: Intermediate ClaudeChatGPT

Podman Host Drift & Storage Reclamation Audit Prompt

Audit a running Podman host for configuration drift from its declared units, orphaned images and containers, and reclaimable storage, then produce a safe cleanup plan.

Target user
SREs and sysadmins maintaining long-lived Podman hosts
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior systems engineer performing a housekeeping audit on a host that has been running containers for a long time without one.

I will provide some or all of:
- `podman system df` and `podman system df -v`
- `podman ps -a`, `podman images -a`, `podman volume ls`, and `podman pod ps`
- The Quadlet units present in `/etc/containers/systemd/` or `~/.config/containers/systemd/`, and `systemctl list-units` output for the generated services
- Filesystem usage for the partition holding container storage
- Whether the host is rootless, rootful, or both (multiple users each with their own storage), and whether `podman auto-update` is in use
- Any constraint: which workloads must not be interrupted, and the maintenance window available

Your job:

1. **Map declared state against running state** — for each Quadlet unit, determine whether a corresponding container is running, whether its image matches the unit's declared image, and whether any running container has no unit behind it. Every container without a declaring unit is drift: it will not come back after a reboot and nobody knows who created it. List these explicitly.
2. **Detect image drift** — compare the image digest each container is actually running against the digest currently behind the tag in the registry, and flag containers running a stale image under a moving tag. Give the `podman auto-update --dry-run` command and explain that it only considers containers labeled for autoupdate, so silence is not proof of currency.
3. **Inventory the storage** — break down `podman system df` into images, containers, volumes, and build cache, and identify the top consumers by size. Distinguish reclaimable from in-use, and reconcile the total against the actual filesystem usage, since a large gap points at something outside Podman's accounting.
4. **Classify orphans by risk** — separate dangling images with no tag and no dependent container (safe), tagged images with no container (usually safe, sometimes a rollback target), stopped containers (check exit codes and age before deleting evidence of a crash), volumes with no container attached (highest risk, may hold the only copy of real data), and leftover buildah working containers visible with `podman ps -a --external`.
5. **Check per-user and per-root storage separately** — note that each rootless user has independent storage under their home, and that a root-only cleanup reclaims nothing from theirs. Give the command to enumerate which users have container storage and how much each holds.
6. **Check storage integrity** — recommend `podman system check` to detect inconsistencies in the storage layers, and explain what its findings mean and why running a repair on a host with active workloads needs a window.
7. **Produce a staged cleanup plan** — order the commands from safest to most destructive, each with the exact filter and a dry-run or listing step first: `podman image prune` for dangling, `podman image prune -a --filter until=<duration>` for aged unused images, `podman container prune --filter until=`, build-cache pruning, and volume removal only after each orphaned volume has been individually justified. State the expected reclaim per step.
8. **Prevent recurrence** — recommend the durable controls: bringing undeclared containers under Quadlet, enabling `podman-auto-update.timer` with the autoupdate label on units that should track a tag, a scheduled prune timer with conservative `until=` filters, pinning images by digest where reproducibility matters, and a storage alert threshold on the container filesystem.

Output as: (a) drift table of declared vs running, (b) stale-image findings, (c) storage breakdown with top consumers, (d) orphan inventory classified by risk, (e) per-user storage findings, (f) integrity check results, (g) staged cleanup commands with expected reclaim, (h) prevention controls.

Never include `podman system prune --all --volumes` or `podman system reset` in a cleanup plan for a host with live workloads — the first removes unattached volumes that may hold the only copy of production data, and the second destroys everything. If aggressive reclamation is genuinely needed, require an explicit per-volume review and a verified backup first.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Housekeeping prompts tend to produce a wall of prune commands, which is exactly the failure this one is built to avoid. The audit starts by reconciling declared state against running state, because the most valuable finding on a long-lived host is not reclaimable bytes — it is the container nobody declared, which will not come back after a reboot and which no unit file explains. Framing undeclared containers as drift rather than as clutter changes the output from a cleanup script into an inventory you can act on.

Classifying orphans by risk is what makes the cleanup safe to execute. Dangling images with no dependents are genuinely disposable; a tagged image with no container might be your rollback target; a stopped container might be crash evidence; and an unattached volume is the single most dangerous thing on the list, because Podman cannot tell the difference between a leftover and the only copy of a database. Ordering the plan from safest to most destructive, with a listing step before each removal, means an operator can stop partway through and still be in a defensible state.

The per-user storage step catches the mistake that makes audits useless on shared hosts: each rootless user has independent storage under their own home, so a root-level system df describes a fraction of the problem and a root-level prune reclaims a fraction of the space. Pairing that with prevention controls — Quadlet adoption, an auto-update timer, a conservative prune timer, and a storage alert — is what keeps the host from arriving back in the same state in six months.

Related prompts

More Podman prompts & error guides

Browse every Podman prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.