Skip to content

Docker & Podman: Clean up & disk

Docker & Podman commands for clean up & disk (tags: #cleanup #disk #backup).

Index
4 items

Docker3

Docker: Show disk used by Docker

Safe

Space used by images, containers, local volumes and build cache, and how much is reclaimable.

docker system df
What each part does
  1. docker system dfdisk used by images, containers, volumes and build cache, with how much is reclaimable; add -v for per-item detail

Also known as: docker disk usage · /var/lib/docker full

Docker: Remove dangling images

Caution

Delete untagged <none> images left over from rebuilds.

docker image prune -f
What each part does
  1. docker image pruneremove dangling images (<none>:<none>, left over from rebuilds)
  2. -fdon't ask for confirmation

Also known as: dangling images · <none> images

Docker: Prune everything unused including volumes

Destructive

Removes stopped containers, unused networks, all unused images, build cache AND unused volumes.

docker system prune -a --volumes -f
What each part does
  1. docker system pruneremove stopped containers, unused networks, dangling images and build cache
  2. -aalso remove every image not used by a container, not just dangling ones
  3. --volumesalso remove volumes not used by a container (data loss)
  4. -fdon't ask for confirmation

My note --volumes deletes data in unused named volumes. Drop it on hosts with local DBs.

Also known as: docker prune · no space left on device · free docker space

Podman1

Podman: Prune everything unused

Destructive

Remove stopped containers, unused pods, images and build cache.

podman system prune -a -f
What each part does
  1. podman system pruneremove stopped containers, unused pods, networks and dangling images
  2. -aalso remove all images not used by a container
  3. -fdon't ask for confirmation

My note Add --volumes to delete unused volumes too.

Also known as: podman prune · no space left on device

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…