Files
Yoan Wainmann d573c171fe docs: clarify multiple --filter behavior in prune commands
Document how multiple --filter flags interact in prune commands:
different filter keys are ANDed (all conditions must match), while
multiple values for the same key are ORed (any value can match).

This addresses a gap in the documentation where users could not
determine whether multiple filters were combined with AND or OR
logic, which is especially important for prune commands where
the wrong assumption could lead to unintended data removal.

Closes #5899

Signed-off-by: Yoan Wainmann <yoan@mreshet.co.il>
2026-03-25 18:13:49 +02:00

2.9 KiB

volume prune

Remove unused local volumes

Options

Name Type Default Description
-a, --all bool Remove all unused volumes, not just anonymous ones
--filter filter Provide filter values (e.g. label=<label>)
-f, --force bool Do not prompt for confirmation

Description

Remove all unused local volumes. Unused local volumes are those which are not referenced by any containers. By default, it only removes anonymous volumes.

Examples

$ docker volume prune

WARNING! This will remove anonymous local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
07c7bdf3e34ab76d921894c2b834f073721fccfbbcba792aa7648e3a7a664c2e

Total reclaimed space: 36 B

Filtering (--all, -a)

Use the --all flag to prune both unused anonymous and named volumes.

Filtering (--filter)

The filtering flag (--filter) format is of "key=value". If there is more than one filter, then pass multiple flags (e.g., --filter "foo=bar" --filter "bif=baz").

When multiple filters are provided, they are combined as follows:

  • Multiple filters with different keys are combined using AND logic. A volume must satisfy all filter conditions to be pruned.
  • Multiple filters with the same key are combined using OR logic. A volume is pruned if it matches any of the values for that key.

For example, --filter "label=foo" --filter "label=bar" prunes volumes that have either the foo or bar label, while --filter "label=foo" --filter "label!=bar" prunes volumes that have the foo label and do not have the bar label.

The currently supported filters are:

  • label (label=<key>, label=<key>=<value>, label!=<key>, or label!=<key>=<value>) - only remove volumes with (or without, in case label!=... is used) the specified labels.

The label filter accepts two formats. One is the label=... (label=<key> or label=<key>=<value>), which removes volumes with the specified labels. The other format is the label!=... (label!=<key> or label!=<key>=<value>), which removes volumes without the specified labels.