1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<h1>docker volume ls</h1> <p><br></p> <p>List volumes</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls [OPTIONS]
</pre></div> <p>Refer to the <a href="#options">options section</a> for an overview of available <a href="#options"><code class="language-plaintext highlighter-rouge">OPTIONS</code></a> for this command.</p> <h2 id="description">Description</h2> <p name="extended-description">List all the volumes known to Docker. You can filter using the <code class="language-plaintext highlighter-rouge">-f</code> or <code class="language-plaintext highlighter-rouge">--filter</code> flag. Refer to the <a href="#filtering">filtering</a> section for more information about available filter options.</p> <p>For example uses of this command, refer to the <a href="#examples">examples section</a> below.</p> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>
<code class="language-plaintext highlighter-rouge">--filter</code> , <code class="language-plaintext highlighter-rouge">-f</code>
</td> <td></td> <td>Provide filter values (e.g. 'dangling=true')</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--format</code></td> <td></td> <td>Pretty-print volumes using a Go template</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--quiet</code> , <code class="language-plaintext highlighter-rouge">-q</code>
</td> <td></td> <td>Only display volume names</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="create-a-volume">Create a volume</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker volume create rosemary
rosemary
$ docker volume create tyler
tyler
$ docker volume ls
DRIVER VOLUME NAME
local rosemary
local tyler
</pre></div> <h3 id="filtering">Filtering</h3> <p>The filtering flag (<code class="language-plaintext highlighter-rouge">-f</code> or <code class="language-plaintext highlighter-rouge">--filter</code>) format is of “key=value”. If there is more than one filter, then pass multiple flags (e.g., <code class="language-plaintext highlighter-rouge">--filter "foo=bar" --filter "bif=baz"</code>)</p> <p>The currently supported filters are:</p> <ul> <li>dangling (boolean - true or false, 0 or 1)</li> <li>driver (a volume driver’s name)</li> <li>label (<code class="language-plaintext highlighter-rouge">label=<key></code> or <code class="language-plaintext highlighter-rouge">label=<key>=<value></code>)</li> <li>name (a volume’s name)</li> </ul> <h4 id="dangling">dangling</h4> <p>The <code class="language-plaintext highlighter-rouge">dangling</code> filter matches on all volumes not referenced by any containers</p> <div class="highlight"><pre class="highlight" data-language="">$ docker run -d -v tyler:/tmpwork busybox
f86a7dd02898067079c99ceacd810149060a70528eff3754d0b0f1a93bd0af18
$ docker volume ls -f dangling=true
DRIVER VOLUME NAME
local rosemary
</pre></div> <h4 id="driver">driver</h4> <p>The <code class="language-plaintext highlighter-rouge">driver</code> filter matches volumes based on their driver.</p> <p>The following example matches volumes that are created with the <code class="language-plaintext highlighter-rouge">local</code> driver:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls -f driver=local
DRIVER VOLUME NAME
local rosemary
local tyler
</pre></div> <h4 id="label">label</h4> <p>The <code class="language-plaintext highlighter-rouge">label</code> filter matches volumes based on the presence of a <code class="language-plaintext highlighter-rouge">label</code> alone or a <code class="language-plaintext highlighter-rouge">label</code> and a value.</p> <p>First, let’s create some volumes to illustrate this;</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume create the-doctor --label is-timelord=yes
the-doctor
$ docker volume create daleks --label is-timelord=no
daleks
</pre></div> <p>The following example filter matches volumes with the <code class="language-plaintext highlighter-rouge">is-timelord</code> label regardless of its value.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls --filter label=is-timelord
DRIVER VOLUME NAME
local daleks
local the-doctor
</pre></div> <p>As the above example demonstrates, both volumes with <code class="language-plaintext highlighter-rouge">is-timelord=yes</code>, and <code class="language-plaintext highlighter-rouge">is-timelord=no</code> are returned.</p> <p>Filtering on both <code class="language-plaintext highlighter-rouge">key</code> <em>and</em> <code class="language-plaintext highlighter-rouge">value</code> of the label, produces the expected result:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls --filter label=is-timelord=yes
DRIVER VOLUME NAME
local the-doctor
</pre></div> <p>Specifying multiple label filter produces an “and” search; all conditions should be met;</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls --filter label=is-timelord=yes --filter label=is-timelord=no
DRIVER VOLUME NAME
</pre></div> <h4 id="name">name</h4> <p>The <code class="language-plaintext highlighter-rouge">name</code> filter matches on all or part of a volume’s name.</p> <p>The following filter matches all volumes with a name containing the <code class="language-plaintext highlighter-rouge">rose</code> string.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls -f name=rose
DRIVER VOLUME NAME
local rosemary
</pre></div> <h3 id="formatting">Formatting</h3> <p>The formatting options (<code class="language-plaintext highlighter-rouge">--format</code>) pretty-prints volumes output using a Go template.</p> <p>Valid placeholders for the Go template are listed below:</p> <table> <thead> <tr> <th>Placeholder</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code class="language-plaintext highlighter-rouge">.Name</code></td> <td>Volume name</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Driver</code></td> <td>Volume driver</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Scope</code></td> <td>Volume scope (local, global)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Mountpoint</code></td> <td>The mount point of the volume on the host</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Labels</code></td> <td>All labels assigned to the volume</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Label</code></td> <td>Value of a specific label for this volume. For example <code class="language-plaintext highlighter-rouge">{{.Label "project.version"}}</code>
</td> </tr> </tbody> </table> <p>When using the <code class="language-plaintext highlighter-rouge">--format</code> option, the <code class="language-plaintext highlighter-rouge">volume ls</code> command will either output the data exactly as the template declares or, when using the <code class="language-plaintext highlighter-rouge">table</code> directive, includes column headers as well.</p> <p>The following example uses a template without headers and outputs the <code class="language-plaintext highlighter-rouge">Name</code> and <code class="language-plaintext highlighter-rouge">Driver</code> entries separated by a colon (<code class="language-plaintext highlighter-rouge">:</code>) for all volumes:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker volume ls --format "{{.Name}}: {{.Driver}}"
vol1: local
vol2: local
vol3: local
</pre></div> <h2 id="parent-command">Parent command</h2> <table> <thead> <tr> <th style="text-align: left">Command</th> <th style="text-align: left">Description</th> </tr> </thead> <tbody> <tr> <td style="text-align: left"><a href="../volume/index">docker volume</a></td> <td style="text-align: left">Manage volumes</td> </tr> </tbody> </table> <h2 id="related-commands">Related commands</h2> <table> <thead> <tr> <td>Command</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><a href="../volume_create/index">docker volume create</a></td> <td>Create a volume</td> </tr> <tr> <td><a href="../volume_inspect/index">docker volume inspect</a></td> <td>Display detailed information on one or more volumes</td> </tr> <tr> <td><a href="index">docker volume ls</a></td> <td>List volumes</td> </tr> <tr> <td><a href="../volume_prune/index">docker volume prune</a></td> <td>Remove all unused local volumes</td> </tr> <tr> <td><a href="../volume_rm/index">docker volume rm</a></td> <td>Remove one or more volumes</td> </tr> </tbody> </table> <div class="_attribution">
<p class="_attribution-p">
© 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
<a href="https://docs.docker.com/engine/reference/commandline/volume_ls/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/volume_ls/</a>
</p>
</div>
|