github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/volume_ls.md (about) 1 # volume ls 2 3 <!---MARKER_GEN_START--> 4 List volumes 5 6 ### Aliases 7 8 `docker volume ls`, `docker volume list` 9 10 ### Options 11 12 | Name | Type | Default | Description | 13 |:---------------------------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 14 | `--cluster` | | | Display only cluster volumes, and use cluster volume list formatting | 15 | [`-f`](#filter), [`--filter`](#filter) | `filter` | | Provide filter values (e.g. `dangling=true`) | 16 | [`--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 | 17 | `-q`, `--quiet` | | | Only display volume names | 18 19 20 <!---MARKER_GEN_END--> 21 22 ## Description 23 24 List all the volumes known to Docker. You can filter using the `-f` or 25 `--filter` flag. Refer to the [filtering](#filter) section for more 26 information about available filter options. 27 28 ## Examples 29 30 ### Create a volume 31 32 ```console 33 $ docker volume create rosemary 34 35 rosemary 36 37 $ docker volume create tyler 38 39 tyler 40 41 $ docker volume ls 42 43 DRIVER VOLUME NAME 44 local rosemary 45 local tyler 46 ``` 47 48 ### <a name="filter"></a> Filtering (--filter) 49 50 The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more 51 than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) 52 53 The currently supported filters are: 54 55 - dangling (Boolean - true or false, 0 or 1) 56 - driver (a volume driver's name) 57 - label (`label=<key>` or `label=<key>=<value>`) 58 - name (a volume's name) 59 60 #### dangling 61 62 The `dangling` filter matches on all volumes not referenced by any containers 63 64 ```console 65 $ docker run -d -v tyler:/tmpwork busybox 66 67 f86a7dd02898067079c99ceacd810149060a70528eff3754d0b0f1a93bd0af18 68 $ docker volume ls -f dangling=true 69 DRIVER VOLUME NAME 70 local rosemary 71 ``` 72 73 #### driver 74 75 The `driver` filter matches volumes based on their driver. 76 77 The following example matches volumes that are created with the `local` driver: 78 79 ```console 80 $ docker volume ls -f driver=local 81 82 DRIVER VOLUME NAME 83 local rosemary 84 local tyler 85 ``` 86 87 #### label 88 89 The `label` filter matches volumes based on the presence of a `label` alone or 90 a `label` and a value. 91 92 First, create some volumes to illustrate this; 93 94 ```console 95 $ docker volume create the-doctor --label is-timelord=yes 96 97 the-doctor 98 $ docker volume create daleks --label is-timelord=no 99 100 daleks 101 ``` 102 103 The following example filter matches volumes with the `is-timelord` label 104 regardless of its value. 105 106 ```console 107 $ docker volume ls --filter label=is-timelord 108 109 DRIVER VOLUME NAME 110 local daleks 111 local the-doctor 112 ``` 113 114 As the above example demonstrates, both volumes with `is-timelord=yes`, and 115 `is-timelord=no` are returned. 116 117 Filtering on both `key` *and* `value` of the label, produces the expected result: 118 119 ```console 120 $ docker volume ls --filter label=is-timelord=yes 121 122 DRIVER VOLUME NAME 123 local the-doctor 124 ``` 125 126 Specifying multiple label filter produces an "and" search; all conditions 127 should be met; 128 129 ```console 130 $ docker volume ls --filter label=is-timelord=yes --filter label=is-timelord=no 131 132 DRIVER VOLUME NAME 133 ``` 134 135 #### name 136 137 The `name` filter matches on all or part of a volume's name. 138 139 The following filter matches all volumes with a name containing the `rose` string. 140 141 ```console 142 $ docker volume ls -f name=rose 143 144 DRIVER VOLUME NAME 145 local rosemary 146 ``` 147 148 ### <a name="format"></a> Format the output (--format) 149 150 The formatting options (`--format`) pretty-prints volumes output 151 using a Go template. 152 153 Valid placeholders for the Go template are listed below: 154 155 | Placeholder | Description | 156 |---------------|---------------------------------------------------------------------------------------| 157 | `.Name` | Volume name | 158 | `.Driver` | Volume driver | 159 | `.Scope` | Volume scope (local, global) | 160 | `.Mountpoint` | The mount point of the volume on the host | 161 | `.Labels` | All labels assigned to the volume | 162 | `.Label` | Value of a specific label for this volume. For example `{{.Label "project.version"}}` | 163 164 When using the `--format` option, the `volume ls` command will either 165 output the data exactly as the template declares or, when using the 166 `table` directive, includes column headers as well. 167 168 The following example uses a template without headers and outputs the 169 `Name` and `Driver` entries separated by a colon (`:`) for all volumes: 170 171 ```console 172 $ docker volume ls --format "{{.Name}}: {{.Driver}}" 173 174 vol1: local 175 vol2: local 176 vol3: local 177 ``` 178 179 To list all volumes in JSON format, use the `json` directive: 180 181 ```console 182 $ docker volume ls --format json 183 {"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"} 184 ``` 185 186 ## Related commands 187 188 * [volume create](volume_create.md) 189 * [volume inspect](volume_inspect.md) 190 * [volume rm](volume_rm.md) 191 * [volume prune](volume_prune.md) 192 * [Understand Data Volumes](https://docs.docker.com/storage/volumes/)