github.com/robertojrojas/docker@v1.9.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=false            Print usage
    19        --type=container|image  Return JSON for specified type, permissible
    20                                values are "image" or "container"
    21        -s, --size=false        Display total file sizes if the type is container
    22  
    23  By default, this will render all results in a JSON array. If a format is
    24  specified, the given template will be executed for each result.
    25  
    26  Go's [text/template](http://golang.org/pkg/text/template/) package
    27  describes all the details of the format.
    28  
    29  ## Examples
    30  
    31  **Get an instance's IP address:**
    32  
    33  For the most part, you can pick out any field from the JSON in a fairly
    34  straightforward manner.
    35  
    36      $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    37  
    38  **Get an instance's MAC Address:**
    39  
    40  For the most part, you can pick out any field from the JSON in a fairly
    41  straightforward manner.
    42  
    43      $ docker inspect '{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    44  
    45  **Get an instance's log path:**
    46  
    47      $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    48  
    49  **List All Port Bindings:**
    50  
    51  One can loop over arrays and maps in the results to produce simple text
    52  output:
    53  
    54      $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
    55  
    56  **Find a Specific Port Mapping:**
    57  
    58  The `.Field` syntax doesn't work when the field name begins with a
    59  number, but the template language's `index` function does. The
    60  `.NetworkSettings.Ports` section contains a map of the internal port
    61  mappings to a list of external address/port objects. To grab just the
    62  numeric public port, you use `index` to find the specific port map, and
    63  then `index` 0 contains the first object inside of that. Then we ask for
    64  the `HostPort` field to get the public address.
    65  
    66      $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
    67  
    68  **Get config:**
    69  
    70  The `.Field` syntax doesn't work when the field contains JSON data, but
    71  the template language's custom `json` function does. The `.config`
    72  section contains complex JSON object, so to grab it as JSON, you use
    73  `json` to convert the configuration object into JSON.
    74  
    75      $ docker inspect --format='{{json .config}}' $INSTANCE_ID