Docker prune commands (system, image, volume, build cache)
Answer: Run docker system prune to remove stopped containers, unused networks, dangling images and unused build cache; add -a for all unused images and --volumes for unused anonymous volumes. Docker does not remove unused objects unless you explicitly ask it to.
Examples
docker system df
docker image prune -a --filter "until=24h"
docker volume prune --all
docker buildx prune
docker system prune -a --volumes -f
docker system prune --filter "label!=keep"
Commands
| Command | Removes by default | |---|---| | docker image prune | dangling images (untagged and unreferenced) | | docker container prune | all stopped containers | | docker volume prune | anonymous unused volumes; named ones need --all | | docker network prune | networks not used by any containers | | docker buildx prune | build cache for the current builder | | docker system prune | stopped containers, unused networks, dangling images, unused build cache |
Flags for system prune
| Option | Description | |---|---| | -a, --all | remove all unused images, not just dangling ones | | --volumes | prune anonymous volumes | | -f, --force | do not prompt for confirmation | | --filter | filter values such as until=24h or a label |
Rules
- Volumes are never removed automatically, because doing so could destroy data. Add
--volumeson system prune to remove unused anonymous volumes. - A stopped container's writable layers still take up space; start short-lived containers with
--rm. - Build cache, including BuildKit cache mounts, is eligible for pruning with
docker system prune. Usedocker builder prunefor cache only. - Each builder maintains its own cache; use
--builderto target one.
See also
Claims
- id: C1 claim: Docker does not remove unused objects unless asked. source: S1 evidence: "These objects are generally not removed unless you explicitly ask Docker to do so."
- id: C2 claim: Volumes are never removed automatically. source: S1 evidence: "Volumes are never removed automatically, because to do so could destroy data."
- id: C3 claim: system prune removes unused data and optionally volumes. source: S2 evidence: "Remove all unused containers, networks, images (both dangling and unused), unused build cache"
Sources
- [S1] Prune unused Docker objects. Docker docs. https://docs.docker.com/engine/manage-resources/pruning/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] docker system prune. Docker CLI reference. https://docs.docker.com/reference/cli/docker/system/prune/ . License: Apache-2.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Prune unused Docker objects; Docker CLI reference, docker system prune. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, Prune unused Docker objects; Docker CLI reference, docker system prune. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Docker prune commands (system, image, volume, build cache)." iinventedlight Library, iil:note:bhatdk94, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-system-prune/. License: CC-BY-4.0.
@misc{iil_note_bhatdk94,
author = {{iinventedlight}},
title = {{Docker prune commands (system, image, volume, build cache)}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/docker-system-prune/},
note = {Permanent ID iil:note:bhatdk94. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- docker-system-prune.table.json (table; CC-BY-4.0)
- docker-system-prune.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-system-prune.md.