github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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  # inspect
     8  
     9  ```markdown
    10  Usage:  docker inspect [OPTIONS] NAME|ID [NAME|ID...]
    11  
    12  Return low-level information on Docker object(s) (e.g. container, image, volume,
    13  network, node, service, or task) identified by name or ID
    14  
    15  Options:
    16    -f, --format       Format the output using the given Go template
    17        --help         Print usage
    18    -s, --size         Display total file sizes if the type is container
    19        --type         Return JSON for specified type
    20  ```
    21  
    22  ## Description
    23  
    24  Docker inspect provides detailed information on constructs controlled by Docker.
    25  
    26  By default, `docker inspect` will render results in a JSON array.
    27  
    28  ## Request a custom response format (--format)
    29  
    30  If a format is specified, the given template will be executed for each result.
    31  
    32  Go's [text/template](http://golang.org/pkg/text/template/) package
    33  describes all the details of the format.
    34  
    35  ## Specify target type (--type)
    36  
    37  `--type container|image|node|network|secret|service|volume|task|plugin`
    38  
    39  The `docker inspect` command matches any type of object by either ID or name.
    40  In some cases multiple type of objects (for example, a container and a volume)
    41  exist with the same name, making the result ambiguous.
    42  
    43  To restrict `docker inspect` to a specific type of object, use the `--type`
    44  option.
    45  
    46  The following example inspects a _volume_ named "myvolume"
    47  
    48  ```bash
    49  $ docker inspect --type=volume myvolume
    50  ```
    51  
    52  ## Examples
    53  
    54  ### Get an instance's IP address
    55  
    56  For the most part, you can pick out any field from the JSON in a fairly
    57  straightforward manner.
    58  
    59  ```bash
    60  $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    61  ```
    62  
    63  ### Get an instance's MAC address
    64  
    65  ```bash
    66  $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    67  ```
    68  
    69  ### Get an instance's log path
    70  
    71  ```bash
    72  $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    73  ```
    74  
    75  ### Get an instance's image name
    76  
    77  ```bash
    78  $ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
    79  ```
    80  
    81  ### List all port bindings
    82  
    83  You can loop over arrays and maps in the results to produce simple text
    84  output:
    85  
    86  ```bash
    87  $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
    88  ```
    89  
    90  ### Find a specific port mapping
    91  
    92  The `.Field` syntax doesn't work when the field name begins with a
    93  number, but the template language's `index` function does. The
    94  `.NetworkSettings.Ports` section contains a map of the internal port
    95  mappings to a list of external address/port objects. To grab just the
    96  numeric public port, you use `index` to find the specific port map, and
    97  then `index` 0 contains the first object inside of that. Then we ask for
    98  the `HostPort` field to get the public address.
    99  
   100  ```bash
   101  $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
   102  ```
   103  
   104  ### Get a subsection in JSON format
   105  
   106  If you request a field which is itself a structure containing other
   107  fields, by default you get a Go-style dump of the inner values.
   108  Docker adds a template function, `json`, which can be applied to get
   109  results in JSON format.
   110  
   111  ```bash
   112  $ docker inspect --format='{{json .Config}}' $INSTANCE_ID
   113  ```