Clean up unused Docker data
Destructive
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Inspects Docker disk usage, then removes unused containers, networks, images, build cache, and anonymous volumes to reclaim local disk space.
dockercleanupdisk
Confirmation required
This recipe is destructive and requires confirmation — confirm you understand the impact before running any command below.
Commands
Inspect Docker disk usage before removing anything
docker system dfRemove all Docker data not referenced by a running container
docker system prune --all --volumesVerification
docker system dfReclaimable disk usage is reduced by the cleanup.
Undo
Not undoable
Removed images, anonymous volumes, and their unbacked data cannot be recovered locally.
Pitfalls
- Unused anonymous volumes are removed and may contain irreplaceable data.
- Named volumes are retained; pruning them requires a separate docker volume prune --all command.
- Images needed later must be downloaded or rebuilt again.