github.com/olljanat/moby@v1.13.1/docs/reference/commandline/inspect.md (about)

     1  ---
     2  title: "inspect"
     3  description: "The inspect command description and usage"
     4  keywords: "inspect, container, json"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/docker Github
     8       repository at https://github.com/docker/docker/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # inspect
    17  
    18  ```markdown
    19  Usage:  docker inspect [OPTIONS] NAME|ID [NAME|ID...]
    20  
    21  Return low-level information on Docker object(s) (e.g. container, image, volume,
    22  network, node, service, or task) identified by name or ID
    23  
    24  Options:
    25    -f, --format       Format the output using the given Go template
    26        --help         Print usage
    27    -s, --size         Display total file sizes if the type is container
    28        --type         Return JSON for specified type
    29  ```
    30  
    31  By default, this will render all results in a JSON array. If the container and
    32  image have the same name, this will return container JSON for unspecified type.
    33  If a format is specified, the given template will be executed for each result.
    34  
    35  Go's [text/template](http://golang.org/pkg/text/template/) package
    36  describes all the details of the format.
    37  
    38  ## Examples
    39  
    40  **Get an instance's IP address:**
    41  
    42  For the most part, you can pick out any field from the JSON in a fairly
    43  straightforward manner.
    44  
    45      {% raw %}
    46      $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    47      {% endraw %}
    48  
    49  **Get an instance's MAC address:**
    50  
    51  For the most part, you can pick out any field from the JSON in a fairly
    52  straightforward manner.
    53  
    54      {% raw %}
    55      $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    56      {% endraw %}
    57  
    58  **Get an instance's log path:**
    59  
    60      {% raw %}
    61      $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    62      {% endraw %}
    63  
    64  **Get a Task's image name:**
    65  
    66      {% raw %}
    67      $ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID
    68      {% endraw %}
    69  
    70  **List all port bindings:**
    71  
    72  One can loop over arrays and maps in the results to produce simple text
    73  output:
    74  
    75      {% raw %}
    76      $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
    77      {% endraw %}
    78  
    79  **Find a specific port mapping:**
    80  
    81  The `.Field` syntax doesn't work when the field name begins with a
    82  number, but the template language's `index` function does. The
    83  `.NetworkSettings.Ports` section contains a map of the internal port
    84  mappings to a list of external address/port objects. To grab just the
    85  numeric public port, you use `index` to find the specific port map, and
    86  then `index` 0 contains the first object inside of that. Then we ask for
    87  the `HostPort` field to get the public address.
    88  
    89      {% raw %}
    90      $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
    91      {% endraw %}
    92  
    93  **Get a subsection in JSON format:**
    94  
    95  If you request a field which is itself a structure containing other
    96  fields, by default you get a Go-style dump of the inner values.
    97  Docker adds a template function, `json`, which can be applied to get
    98  results in JSON format.
    99  
   100      {% raw %}
   101      $ docker inspect --format='{{json .Config}}' $INSTANCE_ID
   102      {% endraw %}