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