diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html | |
new repository
Diffstat (limited to 'devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html')
| -rw-r--r-- | devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html b/devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html new file mode 100644 index 00000000..018d1bd2 --- /dev/null +++ b/devdocs/docker/engine%2Freference%2Fcommandline%2Fimages%2Findex.html @@ -0,0 +1,136 @@ +<h1>docker images</h1> <p><br></p> <p>List images</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker images [OPTIONS] [REPOSITORY[:TAG]] +</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">The default <code class="language-plaintext highlighter-rouge">docker images</code> will show all top level images, their repository and tags, and their size.</p> <p>Docker images have intermediate layers that increase reusability, decrease disk usage, and speed up <code class="language-plaintext highlighter-rouge">docker build</code> by allowing each step to be cached. These intermediate layers are not shown by default.</p> <p>The <code class="language-plaintext highlighter-rouge">SIZE</code> is the cumulative space taken up by the image and all its parent images. This is also the disk space used by the contents of the Tar file created when you <code class="language-plaintext highlighter-rouge">docker save</code> an image.</p> <p>An image will be listed more than once if it has multiple repository names or tags. This single image (identifiable by its matching <code class="language-plaintext highlighter-rouge">IMAGE ID</code>) uses up the <code class="language-plaintext highlighter-rouge">SIZE</code> listed only once.</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>Show all images (default hides intermediate images)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--digests</code></td> <td></td> <td>Show digests</td> </tr> <tr> <td> +<code class="language-plaintext highlighter-rouge">--filter</code> , <code class="language-plaintext highlighter-rouge">-f</code> +</td> <td></td> <td>Filter output based on conditions provided</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--format</code></td> <td></td> <td>Pretty-print images using a Go template</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-trunc</code></td> <td></td> <td>Don't truncate output</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 show image IDs</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="list-the-most-recently-created-images">List the most recently created images</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +<none> <none> 77af4d6b9913 19 hours ago 1.089 GB +committ latest b6fa739cedf5 19 hours ago 1.089 GB +<none> <none> 78a85c484f71 19 hours ago 1.089 GB +docker latest 30557a29d5ab 20 hours ago 1.089 GB +<none> <none> 5ed6274db6ce 24 hours ago 1.089 GB +postgres 9 746b819f315e 4 days ago 213.4 MB +postgres 9.3 746b819f315e 4 days ago 213.4 MB +postgres 9.3.5 746b819f315e 4 days ago 213.4 MB +postgres latest 746b819f315e 4 days ago 213.4 MB +</pre></div> <h3 id="list-images-by-name-and-tag">List images by name and tag</h3> <p>The <code class="language-plaintext highlighter-rouge">docker images</code> command takes an optional <code class="language-plaintext highlighter-rouge">[REPOSITORY[:TAG]]</code> argument that restricts the list to images that match the argument. If you specify <code class="language-plaintext highlighter-rouge">REPOSITORY</code>but no <code class="language-plaintext highlighter-rouge">TAG</code>, the <code class="language-plaintext highlighter-rouge">docker images</code> command lists all images in the given repository.</p> <p>For example, to list all images in the “java” repository, run this command :</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images java + +REPOSITORY TAG IMAGE ID CREATED SIZE +java 8 308e519aac60 6 days ago 824.5 MB +java 7 493d82594c15 3 months ago 656.3 MB +java latest 2711b1d6f3aa 5 months ago 603.9 MB +</pre></div> <p>The <code class="language-plaintext highlighter-rouge">[REPOSITORY[:TAG]]</code> value must be an “exact match”. This means that, for example, <code class="language-plaintext highlighter-rouge">docker images jav</code> does not match the image <code class="language-plaintext highlighter-rouge">java</code>.</p> <p>If both <code class="language-plaintext highlighter-rouge">REPOSITORY</code> and <code class="language-plaintext highlighter-rouge">TAG</code> are provided, only images matching that repository and tag are listed. To find all local images in the “java” repository with tag “8” you can use:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images java:8 + +REPOSITORY TAG IMAGE ID CREATED SIZE +java 8 308e519aac60 6 days ago 824.5 MB +</pre></div> <p>If nothing matches <code class="language-plaintext highlighter-rouge">REPOSITORY[:TAG]</code>, the list is empty.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images java:0 + +REPOSITORY TAG IMAGE ID CREATED SIZE +</pre></div> <h3 id="list-the-full-length-image-ids">List the full length image IDs</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker images --no-trunc + +REPOSITORY TAG IMAGE ID CREATED SIZE +<none> <none> sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB +committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB +<none> <none> sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB +docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB +<none> <none> sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB +<none> <none> sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB +<none> <none> sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB +tryout latest sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB +<none> <none> sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB +</pre></div> <h3 id="list-image-digests">List image digests</h3> <p>Images that use the v2 or later format have a content-addressable identifier called a <code class="language-plaintext highlighter-rouge">digest</code>. As long as the input used to generate the image is unchanged, the digest value is predictable. To list image digest values, use the <code class="language-plaintext highlighter-rouge">--digests</code> flag:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --digests +REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE +localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB +</pre></div> <p>When pushing or pulling to a 2.0 registry, the <code class="language-plaintext highlighter-rouge">push</code> or <code class="language-plaintext highlighter-rouge">pull</code> command output includes the image digest. You can <code class="language-plaintext highlighter-rouge">pull</code> using a digest value. You can also reference by digest in <code class="language-plaintext highlighter-rouge">create</code>, <code class="language-plaintext highlighter-rouge">run</code>, and <code class="language-plaintext highlighter-rouge">rmi</code> commands, as well as the <code class="language-plaintext highlighter-rouge">FROM</code> image reference in a Dockerfile.</p> <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)</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>before (<code class="language-plaintext highlighter-rouge"><image-name>[:<tag>]</code>, <code class="language-plaintext highlighter-rouge"><image id></code> or <code class="language-plaintext highlighter-rouge"><image@digest></code>) - filter images created before given id or references</li> <li>since (<code class="language-plaintext highlighter-rouge"><image-name>[:<tag>]</code>, <code class="language-plaintext highlighter-rouge"><image id></code> or <code class="language-plaintext highlighter-rouge"><image@digest></code>) - filter images created since given id or references</li> <li>reference (pattern of an image reference) - filter images whose reference matches the specified pattern</li> </ul> <h4 id="show-untagged-images-dangling">Show untagged images (dangling)</h4> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "dangling=true" + +REPOSITORY TAG IMAGE ID CREATED SIZE +<none> <none> 8abc22fbb042 4 weeks ago 0 B +<none> <none> 48e5f45168b9 4 weeks ago 2.489 MB +<none> <none> bf747efa0e2f 4 weeks ago 0 B +<none> <none> 980fe10e5736 12 weeks ago 101.4 MB +<none> <none> dea752e4e117 12 weeks ago 101.4 MB +<none> <none> 511136ea3c5a 8 months ago 0 B +</pre></div> <p>This will display untagged images that are the leaves of the images tree (not intermediary layers). These images occur when a new build of an image takes the <code class="language-plaintext highlighter-rouge">repo:tag</code> away from the image ID, leaving it as <code class="language-plaintext highlighter-rouge"><none>:<none></code> or untagged. A warning will be issued if trying to remove an image when a container is presently using it. By having this flag it allows for batch cleanup.</p> <p>You can use this in conjunction with <code class="language-plaintext highlighter-rouge">docker rmi ...</code>:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker rmi $(docker images -f "dangling=true" -q) + +8abc22fbb042 +48e5f45168b9 +bf747efa0e2f +980fe10e5736 +dea752e4e117 +511136ea3c5a +</pre></div> <p>Docker warns you if any containers exist that are using these untagged images.</p> <h4 id="show-images-with-a-given-label">Show images with a given label</h4> <p>The <code class="language-plaintext highlighter-rouge">label</code> filter matches images 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>The following filter matches images with the <code class="language-plaintext highlighter-rouge">com.example.version</code> label regardless of its value.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "label=com.example.version" + +REPOSITORY TAG IMAGE ID CREATED SIZE +match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB +match-me-2 latest dea752e4e117 About a minute ago 188.3 MB +</pre></div> <p>The following filter matches images with the <code class="language-plaintext highlighter-rouge">com.example.version</code> label with the <code class="language-plaintext highlighter-rouge">1.0</code> value.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "label=com.example.version=1.0" + +REPOSITORY TAG IMAGE ID CREATED SIZE +match-me latest 511136ea3c5a About a minute ago 188.3 MB +</pre></div> <p>In this example, with the <code class="language-plaintext highlighter-rouge">0.1</code> value, it returns an empty set because no matches were found.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "label=com.example.version=0.1" +REPOSITORY TAG IMAGE ID CREATED SIZE +</pre></div> <h4 id="filter-images-by-time">Filter images by time</h4> <p>The <code class="language-plaintext highlighter-rouge">before</code> filter shows only images created before the image with given id or reference. For example, having these images:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +image1 latest eeae25ada2aa 4 minutes ago 188.3 MB +image2 latest dea752e4e117 9 minutes ago 188.3 MB +image3 latest 511136ea3c5a 25 minutes ago 188.3 MB +</pre></div> <p>Filtering with <code class="language-plaintext highlighter-rouge">before</code> would give:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "before=image1" + +REPOSITORY TAG IMAGE ID CREATED SIZE +image2 latest dea752e4e117 9 minutes ago 188.3 MB +image3 latest 511136ea3c5a 25 minutes ago 188.3 MB +</pre></div> <p>Filtering with <code class="language-plaintext highlighter-rouge">since</code> would give:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter "since=image3" +REPOSITORY TAG IMAGE ID CREATED SIZE +image1 latest eeae25ada2aa 4 minutes ago 188.3 MB +image2 latest dea752e4e117 9 minutes ago 188.3 MB +</pre></div> <h4 id="filter-images-by-reference">Filter images by reference</h4> <p>The <code class="language-plaintext highlighter-rouge">reference</code> filter shows only images whose reference matches the specified pattern.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +busybox latest e02e811dd08f 5 weeks ago 1.09 MB +busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB +busybox musl 733eb3059dce 5 weeks ago 1.21 MB +busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB +</pre></div> <p>Filtering with <code class="language-plaintext highlighter-rouge">reference</code> would give:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter=reference='busy*:*libc' + +REPOSITORY TAG IMAGE ID CREATED SIZE +busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB +busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB +</pre></div> <p>Filtering with multiple <code class="language-plaintext highlighter-rouge">reference</code> would give, either match A or B:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --filter=reference='busy*:uclibc' --filter=reference='busy*:glibc' + +REPOSITORY TAG IMAGE ID CREATED SIZE +busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB +busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB +</pre></div> <h3 id="format-the-output">Format the output</h3> <p>The formatting option (<code class="language-plaintext highlighter-rouge">--format</code>) will pretty print container 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">.ID</code></td> <td>Image ID</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Repository</code></td> <td>Image repository</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Tag</code></td> <td>Image tag</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Digest</code></td> <td>Image digest</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.CreatedSince</code></td> <td>Elapsed time since the image was created</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.CreatedAt</code></td> <td>Time when the image was created</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">.Size</code></td> <td>Image disk size</td> </tr> </tbody> </table> <p>When using the <code class="language-plaintext highlighter-rouge">--format</code> option, the <code class="language-plaintext highlighter-rouge">image</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, will include column headers as well.</p> <p>The following example uses a template without headers and outputs the <code class="language-plaintext highlighter-rouge">ID</code> and <code class="language-plaintext highlighter-rouge">Repository</code> entries separated by a colon (<code class="language-plaintext highlighter-rouge">:</code>) for all images:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --format "{{.ID}}: {{.Repository}}" + +77af4d6b9913: <none> +b6fa739cedf5: committ +78a85c484f71: <none> +30557a29d5ab: docker +5ed6274db6ce: <none> +746b819f315e: postgres +746b819f315e: postgres +746b819f315e: postgres +746b819f315e: postgres +</pre></div> <p>To list all images with their repository and tag in a table format you can use:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" + +IMAGE ID REPOSITORY TAG +77af4d6b9913 <none> <none> +b6fa739cedf5 committ latest +78a85c484f71 <none> <none> +30557a29d5ab docker latest +5ed6274db6ce <none> <none> +746b819f315e postgres 9 +746b819f315e postgres 9.3 +746b819f315e postgres 9.3.5 +746b819f315e postgres latest +</pre></div> <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/images/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/images/</a> + </p> +</div> |
