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
64
65
66
67
68
69
70
71
72
|
<h1>docker system prune</h1> <p><br></p> <p>Remove unused data</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker system prune [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">Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.</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">--all</code> , <code class="language-plaintext highlighter-rouge">-a</code>
</td> <td></td> <td>Remove all unused images not just dangling ones</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--filter</code></td> <td></td> <td>Provide filter values (e.g. 'label=<key>=<value>')</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--force</code> , <code class="language-plaintext highlighter-rouge">-f</code>
</td> <td></td> <td>Do not prompt for confirmation</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--volumes</code></td> <td></td> <td>Prune volumes</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
f44f9b81948b3919590d5f79a680d8378f1139b41952e219830a33027c80c867
792776e68ac9d75bce4092bc1b5cc17b779bc926ab04f4185aec9bf1c0d4641f
Deleted Networks:
network1
network2
Deleted Images:
untagged: hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
deleted: sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57
deleted: sha256:45761469c965421a92a69cc50e92c01e0cfa94fe026cdd1233445ea00e96289a
Total reclaimed space: 1.84kB
</pre></div> <p>By default, volumes are not removed to prevent important data from being deleted if there is currently no container using the volume. Use the <code class="language-plaintext highlighter-rouge">--volumes</code> flag when running the command to prune volumes as well:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker system prune -a --volumes
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all volumes not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
0998aa37185a1a7036b0e12cf1ac1b6442dcfa30a5c9650a42ed5010046f195b
73958bfb884fa81fa4cc6baf61055667e940ea2357b4036acbbe25a60f442a4d
Deleted Networks:
my-network-a
my-network-b
Deleted Volumes:
named-vol
Deleted Images:
untagged: my-curl:latest
deleted: sha256:7d88582121f2a29031d92017754d62a0d1a215c97e8f0106c586546e7404447d
deleted: sha256:dd14a93d83593d4024152f85d7c63f76aaa4e73e228377ba1d130ef5149f4d8b
untagged: alpine:3.3
deleted: sha256:695f3d04125db3266d4ab7bbb3c6b23aa4293923e762aa2562c54f49a28f009f
untagged: alpine:latest
deleted: sha256:ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96
deleted: sha256:9007f5987db353ec398a223bc5a135c5a9601798ba20a1abba537ea2f8ac765f
deleted: sha256:71fa90c8f04769c9721459d5aa0936db640b92c8c91c9b589b54abd412d120ab
deleted: sha256:bb1c3357b3c30ece26e6604aea7d2ec0ace4166ff34c3616701279c22444c0f3
untagged: my-jq:latest
deleted: sha256:6e66d724542af9bc4c4abf4a909791d7260b6d0110d8e220708b09e4ee1322e1
deleted: sha256:07b3fa89d4b17009eb3988dfc592c7d30ab3ba52d2007832dffcf6d40e3eda7f
deleted: sha256:3a88a5c81eb5c283e72db2dbc6d65cbfd8e80b6c89bb6e714cfaaa0eed99c548
Total reclaimed space: 13.5 MB
</pre></div> <h3 id="filtering">Filtering</h3> <p>The filtering flag (<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>until (<code class="language-plaintext highlighter-rouge"><timestamp></code>) - only remove containers, images, and networks created before given timestamp</li> <li>label (<code class="language-plaintext highlighter-rouge">label=<key></code>, <code class="language-plaintext highlighter-rouge">label=<key>=<value></code>, <code class="language-plaintext highlighter-rouge">label!=<key></code>, or <code class="language-plaintext highlighter-rouge">label!=<key>=<value></code>) - only remove containers, images, networks, and volumes with (or without, in case <code class="language-plaintext highlighter-rouge">label!=...</code> is used) the specified labels.</li> </ul> <p>The <code class="language-plaintext highlighter-rouge">until</code> filter can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. <code class="language-plaintext highlighter-rouge">10m</code>, <code class="language-plaintext highlighter-rouge">1h30m</code>) computed relative to the daemon machine’s time. Supported formats for date formatted time stamps include RFC3339Nano, RFC3339, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05</code>, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05.999999999</code>, <code class="language-plaintext highlighter-rouge">2006-01-02Z07:00</code>, and <code class="language-plaintext highlighter-rouge">2006-01-02</code>. The local timezone on the daemon will be used if you do not provide either a <code class="language-plaintext highlighter-rouge">Z</code> or a <code class="language-plaintext highlighter-rouge">+-00:00</code> timezone offset at the end of the timestamp. When providing Unix timestamps enter seconds[.nanoseconds], where seconds is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long.</p> <p>The <code class="language-plaintext highlighter-rouge">label</code> filter accepts two formats. One is the <code class="language-plaintext highlighter-rouge">label=...</code> (<code class="language-plaintext highlighter-rouge">label=<key></code> or <code class="language-plaintext highlighter-rouge">label=<key>=<value></code>), which removes containers, images, networks, and volumes with the specified labels. The other format is the <code class="language-plaintext highlighter-rouge">label!=...</code> (<code class="language-plaintext highlighter-rouge">label!=<key></code> or <code class="language-plaintext highlighter-rouge">label!=<key>=<value></code>), which removes containers, images, networks, and volumes without the specified labels.</p> <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="../system/index">docker system</a></td> <td style="text-align: left">Manage Docker</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="../system_df/index">docker system df</a></td> <td>Show docker disk usage</td> </tr> <tr> <td><a href="../system_events/index">docker system events</a></td> <td>Get real time events from the server</td> </tr> <tr> <td><a href="../system_info/index">docker system info</a></td> <td>Display system-wide information</td> </tr> <tr> <td><a href="index">docker system prune</a></td> <td>Remove unused data</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/system_prune/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/system_prune/</a>
</p>
</div>
|