Skip to content

Commit 0a7e393

Browse files
author
Yoan Wainmann
committed
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>
1 parent 9637f1b commit 0a7e393

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

docs/reference/commandline/container_prune.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ Total reclaimed space: 212 B
3535
### <a name="filter"></a> Filtering (--filter)
3636

3737
The filtering flag (`--filter`) format is of "key=value". If there is more
38-
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
38+
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`).
39+
40+
When multiple filters are provided, they are combined as follows:
41+
42+
- Multiple filters with **different keys** are combined using AND logic.
43+
A container must satisfy all filter conditions to be pruned.
44+
- Multiple filters with the **same key** are combined using OR logic.
45+
A container is pruned if it matches any of the values for that key.
46+
47+
For example, `--filter "label=foo" --filter "until=24h"` prunes containers
48+
that have the `foo` label **and** were created more than 24 hours ago.
49+
Conversely, `--filter "label=foo" --filter "label=bar"` prunes containers
50+
that have **either** the `foo` **or** `bar` label.
3951

4052
The currently supported filters are:
4153

docs/reference/commandline/image_prune.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,19 @@ Total reclaimed space: 16.43 MB
5858
### <a name="filter"></a> Filtering (--filter)
5959

6060
The filtering flag (`--filter`) format is of "key=value". If there is more
61-
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
61+
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`).
62+
63+
When multiple filters are provided, they are combined as follows:
64+
65+
- Multiple filters with **different keys** are combined using AND logic.
66+
An image must satisfy all filter conditions to be pruned.
67+
- Multiple filters with the **same key** are combined using OR logic.
68+
An image is pruned if it matches any of the values for that key.
69+
70+
For example, `--filter "label=foo" --filter "until=24h"` prunes images
71+
that have the `foo` label **and** were created more than 24 hours ago.
72+
Conversely, `--filter "label=foo" --filter "label=bar"` prunes images
73+
that have **either** the `foo` **or** `bar` label.
6274

6375
The currently supported filters are:
6476

docs/reference/commandline/network_prune.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ n2
3333
### <a name="filter"></a> Filtering (--filter)
3434

3535
The filtering flag (`--filter`) format is of "key=value". If there is more
36-
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
36+
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`).
37+
38+
When multiple filters are provided, they are combined as follows:
39+
40+
- Multiple filters with **different keys** are combined using AND logic.
41+
A network must satisfy all filter conditions to be pruned.
42+
- Multiple filters with the **same key** are combined using OR logic.
43+
A network is pruned if it matches any of the values for that key.
44+
45+
For example, `--filter "label=foo" --filter "until=24h"` prunes networks
46+
that have the `foo` label **and** were created more than 24 hours ago.
47+
Conversely, `--filter "label=foo" --filter "label=bar"` prunes networks
48+
that have **either** the `foo` **or** `bar` label.
3749

3850
The currently supported filters are:
3951

docs/reference/commandline/system_prune.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ Total reclaimed space: 13.5 MB
9797
### <a name="filter"></a> Filtering (--filter)
9898

9999
The filtering flag (`--filter`) format is of "key=value". If there is more
100-
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
100+
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`).
101+
102+
When multiple filters are provided, they are combined as follows:
103+
104+
- Multiple filters with **different keys** are combined using AND logic.
105+
An item must satisfy all filter conditions to be pruned.
106+
- Multiple filters with the **same key** are combined using OR logic.
107+
An item is pruned if it matches any of the values for that key.
108+
109+
For example, `--filter "label=foo" --filter "until=24h"` prunes items
110+
that have the `foo` label **and** were created more than 24 hours ago.
111+
Conversely, `--filter "label=foo" --filter "label=bar"` prunes items
112+
that have **either** the `foo` **or** `bar` label.
101113

102114
The currently supported filters are:
103115

docs/reference/commandline/volume_prune.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ Use the `--all` flag to prune both unused anonymous and named volumes.
3939
### <a name="filter"></a> Filtering (--filter)
4040

4141
The filtering flag (`--filter`) format is of "key=value". If there is more
42-
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
42+
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`).
43+
44+
When multiple filters are provided, they are combined as follows:
45+
46+
- Multiple filters with **different keys** are combined using AND logic.
47+
A volume must satisfy all filter conditions to be pruned.
48+
- Multiple filters with the **same key** are combined using OR logic.
49+
A volume is pruned if it matches any of the values for that key.
50+
51+
For example, `--filter "label=foo" --filter "label=bar"` prunes volumes that
52+
have **either** the `foo` **or** `bar` label, while
53+
`--filter "label=foo" --filter "label!=bar"` prunes volumes that have the
54+
`foo` label **and** do not have the `bar` label.
4355

4456
The currently supported filters are:
4557

0 commit comments

Comments
 (0)