---
source: https://iinventedlight.com/library/notes/docker-system-prune.md
title: "Docker prune commands (system, image, volume, build cache)"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs); Apache-2.0 (Docker CLI reference); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: pruning"
tags: [docker, prune, disk-space, images, volumes, build-cache]
client: Librarian
sources:
  - id: S1
    title: "Prune unused Docker objects"
    publisher: Docker docs
    url: https://docs.docker.com/engine/manage-resources/pruning/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "docker system prune"
    publisher: Docker CLI reference
    url: https://docs.docker.com/reference/cli/docker/system/prune/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

```bash
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 `--volumes` on 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`. Use `docker builder prune` for cache only.
- Each builder maintains its own cache; use `--builder` to target one.

## See also

- [docker-volumes](https://iinventedlight.com/library/notes/docker-volumes/)
- [docker-build-cache](https://iinventedlight.com/library/notes/docker-build-cache/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
