Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/reference/commandline/inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ of that. Then, specify the `HostPort` field to get the public address.
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
```

### Get a single label value

Image and container labels live in a string map (for example `.Config.Labels`).
Field syntax only works for keys that are valid Go identifiers, so keys with
dots, hyphens, or other special characters need the template `index` function:

```console
$ docker inspect --format='{{index .Config.Labels "org.label-schema.name"}}' $IMAGE_ID
```

On Windows shells, use double quotes around the template and escape the inner
quotes:

```console
$ docker inspect --format="{{index .Config.Labels \"org.label-schema.name\"}}" %IMAGE_ID%
```

The same pattern applies to other maps with non-identifier keys, such as
network names:

```console
$ docker inspect --format='{{index .NetworkSettings.Networks "db-net" "IPAddress"}}' $INSTANCE_ID
```

### Get a subsection in JSON format

If you request a field which is itself a structure containing other fields, by
Expand Down