github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/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 ```markdown 14 Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...] 15 16 Return low-level information on one or multiple containers, images, volumes, 17 networks, nodes, services, or tasks identified by name or ID. 18 19 Options: 20 -f, --format Format the output using the given go template 21 --help Print usage 22 -s, --size Display total file sizes if the type is container 23 values are "image" or "container" or "task 24 --type Return JSON for specified type 25 ``` 26 27 By default, this will render all results in a JSON array. If the container and 28 image have the same name, this will return container JSON for unspecified type. 29 If a format is specified, the given template will be executed for each result. 30 31 Go's [text/template](http://golang.org/pkg/text/template/) package 32 describes all the details of the format. 33 34 ## Examples 35 36 **Get an instance's IP address:** 37 38 For the most part, you can pick out any field from the JSON in a fairly 39 straightforward manner. 40 41 $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID 42 43 **Get an instance's MAC address:** 44 45 For the most part, you can pick out any field from the JSON in a fairly 46 straightforward manner. 47 48 $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID 49 50 **Get an instance's log path:** 51 52 $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID 53 54 **Get a Task's image name:** 55 56 $ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID 57 58 **List all port bindings:** 59 60 One can loop over arrays and maps in the results to produce simple text 61 output: 62 63 $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID 64 65 **Find a specific port mapping:** 66 67 The `.Field` syntax doesn't work when the field name begins with a 68 number, but the template language's `index` function does. The 69 `.NetworkSettings.Ports` section contains a map of the internal port 70 mappings to a list of external address/port objects. To grab just the 71 numeric public port, you use `index` to find the specific port map, and 72 then `index` 0 contains the first object inside of that. Then we ask for 73 the `HostPort` field to get the public address. 74 75 $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID 76 77 **Get a subsection in JSON format:** 78 79 If you request a field which is itself a structure containing other 80 fields, by default you get a Go-style dump of the inner values. 81 Docker adds a template function, `json`, which can be applied to get 82 results in JSON format. 83 84 $ docker inspect --format='{{json .Config}}' $INSTANCE_ID