2016-08-31 12:57:32 -04:00
# volume prune
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_START -->
2023-08-12 09:19:17 -04:00
Remove unused local volumes
2016-08-31 12:57:32 -04:00
2023-01-06 13:04:05 -05:00
### Options
2023-04-20 06:54:56 -04:00
| Name | Type | Default | Description |
|:------------------------------|:---------|:--------|:---------------------------------------------------|
2024-07-03 02:29:57 -04:00
| [`-a` ](#all ), [`--all` ](#all ) | `bool` | | Remove all unused volumes, not just anonymous ones |
2023-04-20 06:54:56 -04:00
| [`--filter` ](#filter ) | `filter` | | Provide filter values (e.g. `label=<label>` ) |
2024-07-03 02:29:57 -04:00
| `-f` , `--force` | `bool` | | Do not prompt for confirmation |
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_END -->
2016-08-31 12:57:32 -04:00
2017-02-07 18:42:48 -05:00
## Description
2023-04-20 06:54:56 -04:00
Remove all unused local volumes. Unused local volumes are those which are not
referenced by any containers. By default, it only removes anonymous volumes.
2016-08-31 12:57:32 -04:00
2017-02-07 18:42:48 -05:00
## Examples
2016-08-31 12:57:32 -04:00
2021-08-21 08:54:14 -04:00
```console
2016-08-31 12:57:32 -04:00
$ docker volume prune
2017-02-07 18:42:48 -05:00
2023-04-20 06:54:56 -04:00
WARNING! This will remove anonymous local volumes not used by at least one container.
2016-08-31 12:57:32 -04:00
Are you sure you want to continue? [y/N] y
Deleted Volumes:
07c7bdf3e34ab76d921894c2b834f073721fccfbbcba792aa7648e3a7a664c2e
my-named-vol
Total reclaimed space: 36 B
```
2023-04-20 06:54:56 -04:00
### <a name="all"></a> Filtering (--all, -a)
Use the `--all` flag to prune both unused anonymous and named volumes.
2023-01-06 13:28:29 -05:00
### <a name="filter"></a> Filtering (--filter)
2017-04-10 14:08:40 -04:00
2018-01-02 13:40:23 -05:00
The filtering flag (`--filter`) format is of "key=value". If there is more
2017-04-10 14:08:40 -04:00
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"` )
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.
2017-02-07 18:42:48 -05:00
## Related commands
2016-08-31 12:57:32 -04:00
* [volume create ](volume_create.md )
* [volume ls ](volume_ls.md )
* [volume inspect ](volume_inspect.md )
* [volume rm ](volume_rm.md )
2020-04-19 09:43:08 -04:00
* [Understand Data Volumes ](https://docs.docker.com/storage/volumes/ )
2016-08-31 12:57:32 -04:00
* [system df ](system_df.md )
* [container prune ](container_prune.md )
2016-10-10 11:26:05 -04:00
* [image prune ](image_prune.md )
2016-10-18 00:36:52 -04:00
* [network prune ](network_prune.md )
2016-08-31 12:57:32 -04:00
* [system prune ](system_prune.md )