2015-06-12 09:25:32 -04:00
# volume ls
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_START -->
2016-07-07 14:43:18 -04:00
List volumes
2023-01-06 13:04:05 -05:00
### Aliases
`docker volume ls` , `docker volume list`
### Options
| Name | Type | Default | Description |
|:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--cluster` | | | Display only cluster volumes, and use cluster volume list formatting |
| [`-f` ](#filter ), [`--filter` ](#filter ) | `filter` | | Provide filter values (e.g. `dangling=true` ) |
| [`--format` ](#format ) | `string` | | Format output using a custom template:< br > 'table': Print output in table format with column headers (default)< br > 'table TEMPLATE': Print output in table format using the given Go template< br > 'json': Print in JSON format< br > 'TEMPLATE': Print output using the given Go template.< br > Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
| `-q` , `--quiet` | | | Only display volume names |
<!-- - MARKER_GEN_END -->
2015-06-12 09:25:32 -04:00
2017-02-07 18:42:48 -05:00
## Description
2015-06-12 09:25:32 -04:00
2017-02-07 18:42:48 -05:00
List all the volumes known to Docker. You can filter using the `-f` or
2023-01-06 12:05:02 -05:00
`--filter` flag. Refer to the [filtering ](#filter ) section for more
2017-02-07 18:42:48 -05:00
information about available filter options.
2015-06-12 09:25:32 -04:00
2017-02-07 18:42:48 -05:00
## Examples
### Create a volume
2021-08-21 08:54:14 -04:00
```console
2016-06-14 18:42:30 -04:00
$ docker volume create rosemary
2017-02-07 18:42:48 -05:00
2016-08-15 11:39:50 -04:00
rosemary
2017-02-07 18:42:48 -05:00
$ docker volume create tyler
2016-08-15 11:39:50 -04:00
tyler
2017-02-07 18:42:48 -05:00
2016-08-15 11:39:50 -04:00
$ docker volume ls
2017-02-07 18:42:48 -05:00
2016-08-15 11:39:50 -04:00
DRIVER VOLUME NAME
local rosemary
local tyler
```
2016-03-21 03:39:48 -04:00
2023-01-06 13:28:29 -05:00
### <a name="filter"></a> Filtering (--filter)
2016-03-21 03:39:48 -04:00
The filtering flag (`-f` or `--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"` )
The currently supported filters are:
2023-12-13 09:16:56 -05:00
- dangling (Boolean - true or false, 0 or 1)
2020-04-19 09:43:08 -04:00
- driver (a volume driver's name)
- label (`label=< key > ` or `label=<key>=<value>` )
- name (a volume's name)
2016-03-21 03:39:48 -04:00
2017-02-07 18:42:48 -05:00
#### dangling
2016-03-21 03:39:48 -04:00
The `dangling` filter matches on all volumes not referenced by any containers
2021-08-21 08:54:14 -04:00
```console
2016-08-15 11:39:50 -04:00
$ docker run -d -v tyler:/tmpwork busybox
f86a7dd02898067079c99ceacd810149060a70528eff3754d0b0f1a93bd0af18
$ docker volume ls -f dangling=true
DRIVER VOLUME NAME
local rosemary
```
2016-03-21 03:39:48 -04:00
2017-02-07 18:42:48 -05:00
#### driver
2016-03-21 03:39:48 -04:00
2017-01-04 01:43:29 -05:00
The `driver` filter matches volumes based on their driver.
2016-03-21 03:39:48 -04:00
2017-01-04 01:43:29 -05:00
The following example matches volumes that are created with the `local` driver:
2016-03-21 03:39:48 -04:00
2021-08-21 08:54:14 -04:00
```console
2016-08-15 11:39:50 -04:00
$ docker volume ls -f driver=local
DRIVER VOLUME NAME
local rosemary
local tyler
```
2017-02-07 18:42:48 -05:00
#### label
2016-08-15 11:39:50 -04:00
The `label` filter matches volumes based on the presence of a `label` alone or
a `label` and a value.
2023-12-13 09:16:56 -05:00
First, create some volumes to illustrate this;
2016-08-15 11:39:50 -04:00
2021-08-21 08:54:14 -04:00
```console
2016-06-14 18:42:30 -04:00
$ docker volume create the-doctor --label is-timelord=yes
2017-02-07 18:42:48 -05:00
2016-08-15 11:39:50 -04:00
the-doctor
2016-06-14 18:42:30 -04:00
$ docker volume create daleks --label is-timelord=no
2017-02-07 18:42:48 -05:00
2016-08-15 11:39:50 -04:00
daleks
```
The following example filter matches volumes with the `is-timelord` label
regardless of its value.
2021-08-21 08:54:14 -04:00
```console
2016-08-15 11:39:50 -04:00
$ docker volume ls --filter label=is-timelord
2016-10-17 05:25:58 -04:00
DRIVER VOLUME NAME
2016-08-15 11:39:50 -04:00
local daleks
local the-doctor
```
2017-02-07 18:42:48 -05:00
As the above example demonstrates, both volumes with `is-timelord=yes` , and
2016-08-15 11:39:50 -04:00
`is-timelord=no` are returned.
Filtering on both `key` *and* `value` of the label, produces the expected result:
2021-08-21 08:54:14 -04:00
```console
2016-08-15 11:39:50 -04:00
$ docker volume ls --filter label=is-timelord=yes
2016-10-17 05:25:58 -04:00
DRIVER VOLUME NAME
2016-08-15 11:39:50 -04:00
local the-doctor
```
Specifying multiple label filter produces an "and" search; all conditions
should be met;
2021-08-21 08:54:14 -04:00
```console
2016-08-15 11:39:50 -04:00
$ docker volume ls --filter label=is-timelord=yes --filter label=is-timelord=no
2016-10-17 05:25:58 -04:00
DRIVER VOLUME NAME
2016-08-15 11:39:50 -04:00
```
2016-02-18 14:52:15 -05:00
2017-02-07 18:42:48 -05:00
#### name
2016-03-21 03:39:48 -04:00
The `name` filter matches on all or part of a volume's name.
The following filter matches all volumes with a name containing the `rose` string.
2021-08-21 08:54:14 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker volume ls -f name=rose
2016-03-21 03:39:48 -04:00
2017-02-07 18:42:48 -05:00
DRIVER VOLUME NAME
local rosemary
```
2023-01-06 13:28:29 -05:00
### <a name="format"></a> Format the output (--format)
2016-08-04 08:59:55 -04:00
The formatting options (`--format`) pretty-prints volumes output
using a Go template.
Valid placeholders for the Go template are listed below:
2022-03-30 08:33:44 -04:00
| Placeholder | Description |
|---------------|---------------------------------------------------------------------------------------|
| `.Name` | Volume name |
| `.Driver` | Volume driver |
| `.Scope` | Volume scope (local, global) |
| `.Mountpoint` | The mount point of the volume on the host |
| `.Labels` | All labels assigned to the volume |
| `.Label` | Value of a specific label for this volume. For example `{{.Label "project.version"}}` |
2016-08-04 08:59:55 -04:00
When using the `--format` option, the `volume ls` command will either
output the data exactly as the template declares or, when using the
`table` directive, includes column headers as well.
The following example uses a template without headers and outputs the
2020-04-19 11:23:09 -04:00
`Name` and `Driver` entries separated by a colon (`:`) for all volumes:
2016-08-04 08:59:55 -04:00
2021-08-21 08:54:14 -04:00
```console
2016-08-04 08:59:55 -04:00
$ docker volume ls --format "{{.Name}}: {{.Driver}}"
2017-02-07 18:42:48 -05:00
2016-08-04 08:59:55 -04:00
vol1: local
vol2: local
vol3: local
```
2021-03-09 18:49:33 -05:00
To list all volumes in JSON format, use the `json` directive:
2022-03-30 08:33:44 -04:00
2021-03-09 18:49:33 -05:00
```console
$ docker volume ls --format json
{"Driver":"local","Labels":"","Links":"N/A","Mountpoint":"/var/lib/docker/volumes/docker-cli-dev-cache/_data","Name":"docker-cli-dev-cache","Scope":"local","Size":"N/A"}
```
2017-02-07 18:42:48 -05:00
## Related commands
2016-02-18 14:52:15 -05:00
* [volume create ](volume_create.md )
* [volume inspect ](volume_inspect.md )
* [volume rm ](volume_rm.md )
2016-10-18 06:50:11 -04:00
* [volume prune ](volume_prune.md )
2020-04-19 09:43:08 -04:00
* [Understand Data Volumes ](https://docs.docker.com/storage/volumes/ )