diff --git a/commands/prune.go b/commands/prune.go
index 24574f92a..582c4c50f 100644
--- a/commands/prune.go
+++ b/commands/prune.go
@@ -175,7 +175,7 @@ func pruneCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
flags := cmd.Flags()
flags.BoolVarP(&options.all, "all", "a", false, "Include internal/frontend images")
- flags.Var(&options.filter, "filter", `Provide filter values (e.g., "until=24h")`)
+ flags.Var(&options.filter, "filter", `Provide filter values`)
flags.Var(&options.reservedSpace, "reserved-space", "Amount of disk space always allowed to keep for cache")
flags.Var(&options.minFreeSpace, "min-free-space", "Target amount of free disk space after pruning")
flags.Var(&options.maxUsedSpace, "max-used-space", "Maximum amount of disk space allowed to keep for cache")
diff --git a/docs/reference/buildx_du.md b/docs/reference/buildx_du.md
index d80498c10..bb682759b 100644
--- a/docs/reference/buildx_du.md
+++ b/docs/reference/buildx_du.md
@@ -13,7 +13,7 @@ Disk usage
|:------------------------|:---------|:--------|:-----------------------------------------|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
| `-D`, `--debug` | `bool` | | Enable debug logging |
-| `--filter` | `filter` | | Provide filter values |
+| [`--filter`](#filter) | `filter` | | Provide filter values |
| [`--format`](#format) | `string` | | Format the output |
| [`--verbose`](#verbose) | `bool` | | Shorthand for `--format=pretty` |
@@ -62,6 +62,10 @@ The asterisks (\*) in the default output format indicate the following:
If you prune such a record then you will lose build cache but only metadata
will be deleted as the image still needs to actual storage layers.
+### Provide filter values (--filter)
+
+Same as [`buildx prune --filter`](buildx_prune.md#filter).
+
### Format the output (--format)
The formatting options (`--format`) pretty-prints usage information output
diff --git a/docs/reference/buildx_prune.md b/docs/reference/buildx_prune.md
index f23385abd..242a879a6 100644
--- a/docs/reference/buildx_prune.md
+++ b/docs/reference/buildx_prune.md
@@ -9,17 +9,17 @@ Remove build cache
### Options
-| Name | Type | Default | Description |
-|:------------------------|:---------|:--------|:-------------------------------------------------------|
-| `-a`, `--all` | `bool` | | Include internal/frontend images |
-| [`--builder`](#builder) | `string` | | Override the configured builder instance |
-| `-D`, `--debug` | `bool` | | Enable debug logging |
-| `--filter` | `filter` | | Provide filter values (e.g., `until=24h`) |
-| `-f`, `--force` | `bool` | | Do not prompt for confirmation |
-| `--max-used-space` | `bytes` | `0` | Maximum amount of disk space allowed to keep for cache |
-| `--min-free-space` | `bytes` | `0` | Target amount of free disk space after pruning |
-| `--reserved-space` | `bytes` | `0` | Amount of disk space always allowed to keep for cache |
-| `--verbose` | `bool` | | Provide a more verbose output |
+| Name | Type | Default | Description |
+|:--------------------------------------|:---------|:--------|:-------------------------------------------------------|
+| [`-a`](#all), [`--all`](#all) | `bool` | | Include internal/frontend images |
+| [`--builder`](#builder) | `string` | | Override the configured builder instance |
+| `-D`, `--debug` | `bool` | | Enable debug logging |
+| [`--filter`](#filter) | `filter` | | Provide filter values |
+| `-f`, `--force` | `bool` | | Do not prompt for confirmation |
+| [`--max-used-space`](#max-used-space) | `bytes` | `0` | Maximum amount of disk space allowed to keep for cache |
+| [`--min-free-space`](#min-free-space) | `bytes` | `0` | Target amount of free disk space after pruning |
+| [`--reserved-space`](#reserved-space) | `bytes` | `0` | Amount of disk space always allowed to keep for cache |
+| `--verbose` | `bool` | | Provide a more verbose output |
@@ -28,24 +28,89 @@ Remove build cache
Clears the build cache of the selected builder.
-You can finely control what cache data is kept using:
-
-- The `--filter=until=` flag to keep images that have been used in
- the last `` time.
-
- `` is a duration string, e.g. `24h` or `2h30m`, with allowable
- units of `(h)ours`, `(m)inutes` and `(s)econds`.
-
-- The `--keep-storage=` flag to keep `` bytes of data in the cache.
-
- `` is a human-readable memory string, e.g. `128mb`, `2gb`, etc. Units
- are case-insensitive.
-
-- The `--all` flag to allow clearing internal helper images and frontend images
- set using the `#syntax=` directive or the `BUILDKIT_SYNTAX` build argument.
-
## Examples
+### Include internal/frontend images (--all)
+
+The `--all` flag to allow clearing internal helper images and frontend images
+set using the `#syntax=` directive or the `BUILDKIT_SYNTAX` build argument.
+
+### Provide filter values (--filter)
+
+You can finely control which cache records to delete using the `--filter` flag.
+
+The filter format is in the form of ``, known as selectors. All
+selectors must match the target object for the filter to be true. We define the
+operators `=` for equality, `!=` for not equal and `~=` for a regular
+expression.
+
+Valid filter keys are:
+- `until` flag to keep records that have been used in the last duration time.
+ Value is a duration string, e.g. `24h` or `2h30m`, with allowable units of
+ `(h)ours`, `(m)inutes` and `(s)econds`.
+- `id` flag to target a specific image ID.
+- `parents` flag to target records that are parents of the
+ specified image ID. Multiple parent IDs are separated by a semicolon (`;`).
+- `description` flag to target records whose description is the specified
+ substring.
+- `inuse` flag to target records that are actively in use and therefore not
+ reclaimable.
+- `mutable` flag to target records that are mutable.
+- `immutable` flag to target records that are immutable.
+- `shared` flag to target records that are shared with other resources,
+ typically images.
+- `private` flag to target records that are not shared.
+- `type` flag to target records by type. Valid types are:
+ - `internal`
+ - `frontend`
+ - `source.local`
+ - `source.git.checkout`
+ - `exec.cachemount`
+ - `regular`
+
+Examples:
+
+```console
+docker buildx prune --filter "until=24h"
+docker buildx prune --filter "description~=golang"
+docker buildx prune --filter "parents=dpetmoi6n0yqanxjqrbnofz9n;kgoj0q6g57i35gdyrv546alz7"
+docker buildx prune --filter "type=source.local"
+docker buildx prune --filter "type!=exec.cachemount"
+```
+
+> [!NOTE]
+> Multiple `--filter` flags are ANDed together.
+
+### Maximum amount of disk space allowed to keep for cache (--max-used-space)
+
+The `--max-used-space` flag allows setting a maximum amount of disk space
+that the build cache can use. If the cache is using more disk space than this
+value, the least recently used cache records are deleted until the total
+used space is less than or equal to the specified value.
+
+The value is specified in bytes. You can use a human-readable memory string,
+e.g. `128mb`, `2gb`, etc. Units are case-insensitive.
+
+### Target amount of free disk space after pruning (--min-free-space)
+
+The `--min-free-space` flag allows setting a target amount of free disk space
+that should be available after pruning. If the available disk space is less
+than this value, the least recently used cache records are deleted until
+the available free space is greater than or equal to the specified value.
+
+The value is specified in bytes. You can use a human-readable memory string,
+e.g. `128mb`, `2gb`, etc. Units are case-insensitive.
+
+### Amount of disk space always allowed to keep for cache (--reserved-space)
+
+The `--reserved-space` flag allows setting an amount of disk space that
+should always be kept for the build cache. If the available disk space is less
+than this value, the least recently used cache records are deleted until
+the available free space is greater than or equal to the specified value.
+
+The value is specified in bytes. You can use a human-readable memory string,
+e.g. `128mb`, `2gb`, etc. Units are case-insensitive.
+
### Override the configured builder instance (--builder)
Same as [`buildx --builder`](buildx.md#builder).