Skip to content

Commit 512607a

Browse files
authored
Merge pull request #6889 from YoanWai/docs/prune-filter-behavior
docs: clarify multiple --filter behavior in prune commands
2 parents 753b102 + d573c17 commit 512607a

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)