diff options
Diffstat (limited to 'devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html')
| -rw-r--r-- | devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html b/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html new file mode 100644 index 00000000..c999cd8d --- /dev/null +++ b/devdocs/docker/engine%2Freference%2Fcommandline%2Finspect%2Findex.html @@ -0,0 +1,18 @@ +<h1>docker inspect</h1> <p><br></p> <p>Return low-level information on Docker objects</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect [OPTIONS] NAME|ID [NAME|ID...] +</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">Docker inspect provides detailed information on constructs controlled by Docker.</p> <p>By default, <code class="language-plaintext highlighter-rouge">docker inspect</code> will render results in a JSON array.</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">--format</code> , <code class="language-plaintext highlighter-rouge">-f</code> +</td> <td></td> <td>Format the output using the given Go template</td> </tr> <tr> <td> +<code class="language-plaintext highlighter-rouge">--size</code> , <code class="language-plaintext highlighter-rouge">-s</code> +</td> <td></td> <td>Display total file sizes if the type is container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--type</code></td> <td></td> <td>Return JSON for specified type</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="get-an-instances-ip-address">Get an instance’s IP address</h3> <p>For the most part, you can pick out any field from the JSON in a fairly straightforward manner.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID +</pre></div> <h3 id="get-an-instances-mac-address">Get an instance’s MAC address</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID +</pre></div> <h3 id="get-an-instances-log-path">Get an instance’s log path</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID +</pre></div> <h3 id="get-an-instances-image-name">Get an instance’s image name</h3> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID +</pre></div> <h3 id="list-all-port-bindings">List all port bindings</h3> <p>You can loop over arrays and maps in the results to produce simple text output:</p> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID +</pre></div> <h3 id="find-a-specific-port-mapping">Find a specific port mapping</h3> <p>The <code class="language-plaintext highlighter-rouge">.Field</code> syntax doesn’t work when the field name begins with a number, but the template language’s <code class="language-plaintext highlighter-rouge">index</code> function does. The <code class="language-plaintext highlighter-rouge">.NetworkSettings.Ports</code> section contains a map of the internal port mappings to a list of external address/port objects. To grab just the numeric public port, you use <code class="language-plaintext highlighter-rouge">index</code> to find the specific port map, and then <code class="language-plaintext highlighter-rouge">index</code> 0 contains the first object inside of that. Then we ask for the <code class="language-plaintext highlighter-rouge">HostPort</code> field to get the public address.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID +</pre></div> <h3 id="get-a-subsection-in-json-format">Get a subsection in JSON format</h3> <p>If you request a field which is itself a structure containing other fields, by default you get a Go-style dump of the inner values. Docker adds a template function, <code class="language-plaintext highlighter-rouge">json</code>, which can be applied to get results in JSON format.</p> <div class="highlight"><pre class="highlight" data-language="">$ docker inspect --format='{{json .Config}}' $INSTANCE_ID +</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/inspect/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/inspect/</a> + </p> +</div> |
