diff options
| author | Misty Stanley-Jones <misty@apache.org> | 2017-04-03 16:54:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-03 16:54:34 -0700 |
| commit | 473c5701cb66403b0535a5c01845cb0f27fbeb47 (patch) | |
| tree | 9a40326ad4b426655abca7377dc30da003847d4d /docs/reference/commandline/inspect.md | |
| parent | ce07fb6b0f1b8765b92022e45f96bd4349812e06 (diff) | |
| parent | 71e6babfa2598669218177b5b429e873b7f35e8f (diff) | |
| download | docker-1.13.x.tar.gz | |
Merge pull request #32332 from mstanleyjones/1.13.x1.13.x
Cherry-pick command-line ref improvements
Diffstat (limited to 'docs/reference/commandline/inspect.md')
| -rw-r--r-- | docs/reference/commandline/inspect.md | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/docs/reference/commandline/inspect.md b/docs/reference/commandline/inspect.md index 7a0c3a0871..842faf9b49 100644 --- a/docs/reference/commandline/inspect.md +++ b/docs/reference/commandline/inspect.md @@ -28,7 +28,9 @@ Options: --type Return JSON for specified type ``` -By default, this will render all results in a JSON array. If the container and +## Description + +By default, `docker inspect` will render all results in a JSON array. If the container and image have the same name, this will return container JSON for unspecified type. If a format is specified, the given template will be executed for each result. @@ -37,46 +39,43 @@ describes all the details of the format. ## Examples -**Get an instance's IP address:** +### Get an instance's IP address For the most part, you can pick out any field from the JSON in a fairly straightforward manner. - {% raw %} - $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID - {% endraw %} - -**Get an instance's MAC address:** +```bash +$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID +``` -For the most part, you can pick out any field from the JSON in a fairly -straightforward manner. +### Get an instance's MAC address - {% raw %} - $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID +``` -**Get an instance's log path:** +### Get an instance's log path - {% raw %} - $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID +``` -**Get a Task's image name:** +### Get an instance's image name - {% raw %} - $ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID +``` -**List all port bindings:** +### List all port bindings -One can loop over arrays and maps in the results to produce simple text +You can loop over arrays and maps in the results to produce simple text output: - {% raw %} - $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID +``` -**Find a specific port mapping:** +### Find a specific port mapping The `.Field` syntax doesn't work when the field name begins with a number, but the template language's `index` function does. The @@ -86,17 +85,17 @@ numeric public port, you use `index` to find the specific port map, and then `index` 0 contains the first object inside of that. Then we ask for the `HostPort` field to get the public address. - {% raw %} - $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID +``` -**Get a subsection in JSON format:** +### Get a subsection in JSON format 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, `json`, which can be applied to get results in JSON format. - {% raw %} - $ docker inspect --format='{{json .Config}}' $INSTANCE_ID - {% endraw %} +```bash +$ docker inspect --format='{{json .Config}}' $INSTANCE_ID +``` |
