github.com/45cali/docker@v1.11.1/docs/reference/commandline/inspect.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "inspect"
     4  description = "The inspect command description and usage"
     5  keywords = ["inspect, container, json"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # inspect
    12  
    13      Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
    14  
    15      Return low-level information on a container or image
    16  
    17        -f, --format=""         Format the output using the given go template
    18        --help                  Print usage
    19        --type=container|image  Return JSON for specified type, permissible
    20                                values are "image" or "container"
    21        -s, --size              Display total file sizes if the type is container
    22  
    23  By default, this will render all results in a JSON array. If the container and
    24  image have the same name, this will return container JSON for unspecified type.
    25  If a format is specified, the given template will be executed for each result.
    26  
    27  Go's [text/template](http://golang.org/pkg/text/template/) package
    28  describes all the details of the format.
    29  
    30  ## Examples
    31  
    32  **Get an instance's IP address:**
    33  
    34  For the most part, you can pick out any field from the JSON in a fairly
    35  straightforward manner.
    36  
    37      $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    38  
    39  **Get an instance's MAC Address:**
    40  
    41  For the most part, you can pick out any field from the JSON in a fairly
    42  straightforward manner.
    43  
    44      $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    45  
    46  **Get an instance's log path:**
    47  
    48      $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    49  
    50  **List All Port Bindings:**
    51  
    52  One can loop over arrays and maps in the results to produce simple text
    53  output:
    54  
    55      $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
    56  
    57  **Find a Specific Port Mapping:**
    58  
    59  The `.Field` syntax doesn't work when the field name begins with a
    60  number, but the template language's `index` function does. The
    61  `.NetworkSettings.Ports` section contains a map of the internal port
    62  mappings to a list of external address/port objects. To grab just the
    63  numeric public port, you use `index` to find the specific port map, and
    64  then `index` 0 contains the first object inside of that. Then we ask for
    65  the `HostPort` field to get the public address.
    66  
    67      $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
    68  
    69  **Get a subsection in JSON format:**
    70  
    71  If you request a field which is itself a structure containing other
    72  fields, by default you get a Go-style dump of the inner values.
    73  Docker adds a template function, `json`, which can be applied to get
    74  results in JSON format.
    75  
    76      $ docker inspect --format='{{json .Config}}' $INSTANCE_ID