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