Files
docker-docs/_data/engine-cli-edge/docker_inspect.yaml
Misty Stanley-Jones 9c648cf079 Docker 17.05 docs (#3092)
* Add Netlify build script

* Pull 'edge' stuff from master for now

* Add env-regex logging opt (#2688)

* Update Dockerfile to pull from 17.05 branch

* Update YAML files from 17.05.x branch

* Add scaffolding for 17.05 content

* Document highlights for 17.05

* Add v1.29 API

* Document multi-stage builds
2017-05-05 19:50:22 +00:00

82 lines
2.4 KiB
YAML

command: docker inspect
short: Return low-level information on Docker objects
long: |-
ker inspect provides detailed information on constructs controlled by Docker.
By default, `docker inspect` will render results in a JSON array.
usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
pname: docker
plink: docker.yaml
options:
- option: format
shorthand: f
description: Format the output using the given Go template
- option: size
shorthand: s
default_value: "false"
description: Display total file sizes if the type is container
- option: type
description: Return JSON for specified type
examples: |-
### Get an instance's IP address
For the most part, you can pick out any field from the JSON in a fairly
straightforward manner.
```bash
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
```
### Get an instance's MAC address
```bash
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
```
### Get an instance's log path
```bash
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
```
### Get an instance's image name
```bash
$ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
```
### List all port bindings
You can loop over arrays and maps in the results to produce simple text
output:
```bash
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
```
### Find a specific port mapping
The `.Field` syntax doesn't work when the field name begins with a
number, but the template language's `index` function does. The
`.NetworkSettings.Ports` section contains a map of the internal port
mappings to a list of external address/port objects. To grab just the
numeric public port, you use `index` to find the specific port map, and
then `index` 0 contains the first object inside of that. Then we ask for
the `HostPort` field to get the public address.
```bash
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
```
### Get a subsection in JSON format
If you request a field which is itself a structure containing other
fields, by default you get a Go-style dump of the inner values.
Docker adds a template function, `json`, which can be applied to get
results in JSON format.
```bash
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID
```