Disable Liquid templating for blocks with `{{`

Instead of disabling templating for entire files, fix instances
individually by wrapping blocks in:

    ```{% raw %}
    ... content ...
    {% endraw %}```

Signed-off-by: Benjamin R. Haskell <docker@benizi.com>
This commit is contained in:
Benjamin R. Haskell 2016-10-07 00:39:15 -04:00
parent 65ec3a3763
commit 362e94b2bc
33 changed files with 241 additions and 23 deletions

View File

@ -33,34 +33,46 @@ This is the complete list of the available functions with examples:
Join concatenates a list of strings to create a single string. Join concatenates a list of strings to create a single string.
It puts a separator between each element in the list. It puts a separator between each element in the list.
{% raw %}
$ docker ps --format '{{join .Names " or "}}' $ docker ps --format '{{join .Names " or "}}'
{% endraw %}
### Json ### Json
Json encodes an element as a json string. Json encodes an element as a json string.
{% raw %}
$ docker inspect --format '{{json .Mounts}}' container $ docker inspect --format '{{json .Mounts}}' container
{% endraw %}
### Lower ### Lower
Lower turns a string into its lower case representation. Lower turns a string into its lower case representation.
{% raw %}
$ docker inspect --format "{{lower .Name}}" container $ docker inspect --format "{{lower .Name}}" container
{% endraw %}
### Split ### Split
Split slices a string into a list of strings separated by a separator. Split slices a string into a list of strings separated by a separator.
{% raw %}
# docker inspect --format '{{split (join .Names "/") "/"}}' container # docker inspect --format '{{split (join .Names "/") "/"}}' container
{% endraw %}
### Title ### Title
Title capitalizes a string. Title capitalizes a string.
{% raw %}
$ docker inspect --format "{{title .Name}}" container $ docker inspect --format "{{title .Name}}" container
{% endraw %}
### Upper ### Upper
Upper turns a string into its upper case representation. Upper turns a string into its upper case representation.
{% raw %}
$ docker inspect --format "{{upper .Name}}" container $ docker inspect --format "{{upper .Name}}" container
{% endraw %}

View File

@ -33,8 +33,10 @@ The `docker logs` command is not available for this logging driver.
Some options are supported by specifying `--log-opt` as many times as needed: Some options are supported by specifying `--log-opt` as many times as needed:
{% raw %}
- `fluentd-address`: specify `host:port` to connect `localhost:24224` - `fluentd-address`: specify `host:port` to connect `localhost:24224`
- `tag`: specify tag for fluentd message, which interpret some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}` - `tag`: specify tag for fluentd message, which interpret some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}`
{% endraw %}
Configure the default logging driver by passing the Configure the default logging driver by passing the

View File

@ -23,6 +23,7 @@ docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 --l
Docker supports some special template markup you can use when specifying a tag's value: Docker supports some special template markup you can use when specifying a tag's value:
{% raw %}
| Markup | Description | | Markup | Description |
|--------------------|------------------------------------------------------| |--------------------|------------------------------------------------------|
| `{{.ID}}` | The first 12 characters of the container id. | | `{{.ID}}` | The first 12 characters of the container id. |
@ -34,15 +35,18 @@ Docker supports some special template markup you can use when specifying a tag's
| `{{.DaemonName}}` | The name of the docker program (`docker`). | | `{{.DaemonName}}` | The name of the docker program (`docker`). |
For example, specifying a `--log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"` value yields `syslog` log lines like: For example, specifying a `--log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"` value yields `syslog` log lines like:
{% endraw %}
``` ```
Aug 7 18:33:19 HOSTNAME docker/hello-world/foobar/5790672ab6a0[9103]: Hello from Docker. Aug 7 18:33:19 HOSTNAME docker/hello-world/foobar/5790672ab6a0[9103]: Hello from Docker.
``` ```
{% raw %}
At startup time, the system sets the `container_name` field and `{{.Name}}` in At startup time, the system sets the `container_name` field and `{{.Name}}` in
the tags. If you use `docker rename` to rename a container, the new name is not the tags. If you use `docker rename` to rename a container, the new name is not
reflected in the log messages. Instead, these messages continue to use the reflected in the log messages. Instead, these messages continue to use the
original container name. original container name.
{% endraw %}
For advanced usage, the generated tag's use [go For advanced usage, the generated tag's use [go
templates](http://golang.org/pkg/text/template/) and the container's [logging templates](http://golang.org/pkg/text/template/) and the container's [logging
@ -50,14 +54,14 @@ context](https://github.com/docker/docker/blob/master/daemon/logger/context.go).
As an example of what is possible with the syslog logger: As an example of what is possible with the syslog logger:
``` ```{% raw %}
$ docker run -it --rm \ $ docker run -it --rm \
--log-driver syslog \ --log-driver syslog \
--log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \ --log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \
--log-opt env=SOME_ENV_VAR \ --log-opt env=SOME_ENV_VAR \
-e SOME_ENV_VAR=logtester.1234 \ -e SOME_ENV_VAR=logtester.1234 \
flyinprogrammer/logtester flyinprogrammer/logtester
``` {% endraw %}```
Results in logs like this: Results in logs like this:

View File

@ -243,13 +243,13 @@ logging driver options.
For example, to specify both additional options: For example, to specify both additional options:
```bash ```bash{% raw %}
$ docker run -dit \ $ docker run -dit \
--log-driver=fluentd \ --log-driver=fluentd \
--log-opt fluentd-address=localhost:24224 \ --log-opt fluentd-address=localhost:24224 \
--log-opt tag="docker.{{.Name}}" \ --log-opt tag="docker.{{.Name}}" \
alpine sh alpine sh
``` {% endraw %}```
If container cannot connect to the Fluentd daemon on the specified address and If container cannot connect to the Fluentd daemon on the specified address and
`fluentd-async-connect` is not enabled, the container stops immediately. `fluentd-async-connect` is not enabled, the container stops immediately.

View File

@ -33,6 +33,7 @@ You can set the logging driver for a specific container by using the
You can use the `--log-opt NAME=VALUE` flag to specify these additional Splunk You can use the `--log-opt NAME=VALUE` flag to specify these additional Splunk
logging driver options: logging driver options:
{% raw %}
| Option | Required | Description | | Option | Required | Description |
|-----------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `splunk-token` | required | Splunk HTTP Event Collector token. | | `splunk-token` | required | Splunk HTTP Event Collector token. |
@ -46,6 +47,7 @@ logging driver options:
| `tag` | optional | Specify tag for message, which interpret some markup. Default value is `{{.ID}}` (12 characters of the container ID). Refer to the [log tag option documentation](log_tags.md) for customizing the log tag format. | | `tag` | optional | Specify tag for message, which interpret some markup. Default value is `{{.ID}}` (12 characters of the container ID). Refer to the [log tag option documentation](log_tags.md) for customizing the log tag format. |
| `labels` | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for container. | | `labels` | optional | Comma-separated list of keys of labels, which should be included in message, if these labels are specified for container. |
| `env` | optional | Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for container. | | `env` | optional | Comma-separated list of keys of environment variables, which should be included in message, if these variables are specified for container. |
{% endraw %}
If there is collision between `label` and `env` keys, the value of the `env` takes precedence. If there is collision between `label` and `env` keys, the value of the `env` takes precedence.
Both options add additional fields to the attributes of a logging message. Both options add additional fields to the attributes of a logging message.
@ -56,6 +58,7 @@ Docker daemon is running. The path to the root certificate and Common Name is
specified using an HTTPS scheme. This is used for verification. specified using an HTTPS scheme. This is used for verification.
The `SplunkServerDefaultCert` is automatically generated by Splunk certificates. The `SplunkServerDefaultCert` is automatically generated by Splunk certificates.
{% raw %}
docker run --log-driver=splunk \ docker run --log-driver=splunk \
--log-opt splunk-token=176FCEBF-4CF5-4EDF-91BC-703796522D20 \ --log-opt splunk-token=176FCEBF-4CF5-4EDF-91BC-703796522D20 \
--log-opt splunk-url=https://splunkhost:8088 \ --log-opt splunk-url=https://splunkhost:8088 \
@ -67,3 +70,4 @@ The `SplunkServerDefaultCert` is automatically generated by Splunk certificates.
--env "TEST=false" --env "TEST=false"
--label location=west --label location=west
your/application your/application
{% endraw %}

View File

@ -106,7 +106,9 @@ Log tags are now generated in a standard way across different logging drivers.
Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and
`fluentd-tag` have been deprecated in favor of the generic `tag` option. `fluentd-tag` have been deprecated in favor of the generic `tag` option.
{% raw %}
docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}" docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
{% endraw %}
### LXC built-in exec driver ### LXC built-in exec driver
**Deprecated In Release: [v1.8.0](https://github.com/docker/docker/releases/tag/v1.8.0)** **Deprecated In Release: [v1.8.0](https://github.com/docker/docker/releases/tag/v1.8.0)**

View File

@ -523,7 +523,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -598,7 +600,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -902,7 +906,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -982,7 +988,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1075,7 +1083,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1181,7 +1191,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1942,7 +1954,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -537,7 +537,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -614,7 +616,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -939,7 +943,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1019,7 +1025,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1112,7 +1120,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1223,7 +1233,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2023,7 +2035,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -546,7 +546,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -623,7 +625,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -948,7 +952,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1028,7 +1034,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1123,7 +1131,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1169,7 +1179,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1224,7 +1236,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1350,7 +1364,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2176,7 +2192,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -615,7 +615,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -692,7 +694,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1029,7 +1033,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1109,7 +1115,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1204,7 +1212,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1250,7 +1260,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1305,7 +1317,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1431,7 +1445,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2334,7 +2350,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -740,7 +740,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -817,7 +819,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1200,7 +1204,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1284,7 +1290,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1382,7 +1390,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1428,7 +1438,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1483,7 +1495,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1609,7 +1623,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2728,7 +2744,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -766,7 +766,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -843,7 +845,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1233,7 +1237,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1317,7 +1323,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1415,7 +1423,9 @@ Copy files or folders of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1461,7 +1471,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1516,7 +1528,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1642,7 +1656,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2802,7 +2818,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -798,7 +798,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -876,7 +878,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1262,7 +1266,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1346,7 +1352,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1460,7 +1468,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1515,7 +1525,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1643,7 +1655,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2816,7 +2830,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -805,7 +805,9 @@ Get `stdout` and `stderr` logs from the container ``id``
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -883,7 +885,9 @@ Export the contents of container `id`
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/octet-stream Content-Type: application/octet-stream
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Status codes**: **Status codes**:
@ -1269,7 +1273,9 @@ Attach to the container `id`
Connection: Upgrade Connection: Upgrade
Upgrade: tcp Upgrade: tcp
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1353,7 +1359,9 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
**Example response** **Example response**
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**Query parameters**: **Query parameters**:
@ -1467,7 +1475,9 @@ Get a tar archive of a resource in the filesystem of container `id`.
Content-Type: application/x-tar Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about base64-encoded JSON object containing some filesystem header information about
@ -1522,7 +1532,9 @@ Upload a tar archive to be extracted to a path in the filesystem of container
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar Content-Type: application/x-tar
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -1650,7 +1662,9 @@ Build an image from a Dockerfile
POST /build HTTP/1.1 POST /build HTTP/1.1
{% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
{% endraw %}
**Example response**: **Example response**:
@ -2832,7 +2846,9 @@ interactive session with the `exec` command.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/vnd.docker.raw-stream Content-Type: application/vnd.docker.raw-stream
{% raw %}
{{ STREAM }} {{ STREAM }}
{% endraw %}
**JSON parameters**: **JSON parameters**:

View File

@ -145,6 +145,7 @@ directives, see the [**Formatting** section in the `docker images` documentation
Following is a sample `config.json` file: Following is a sample `config.json` file:
{% raw %}
{ {
"HttpHeaders": { "HttpHeaders": {
"MyHeader": "MyValue" "MyHeader": "MyValue"
@ -153,6 +154,7 @@ Following is a sample `config.json` file:
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}", "imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
"detachKeys": "ctrl-e,e" "detachKeys": "ctrl-e,e"
} }
{% endraw %}
### Notary ### Notary

View File

@ -55,6 +55,7 @@ created. Supported `Dockerfile` instructions:
## Commit a container with new configurations ## Commit a container with new configurations
{% raw %}
$ docker ps $ docker ps
ID IMAGE COMMAND CREATED STATUS PORTS ID IMAGE COMMAND CREATED STATUS PORTS
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
@ -65,6 +66,7 @@ created. Supported `Dockerfile` instructions:
f5283438590d f5283438590d
$ docker inspect -f "{{ .Config.Env }}" f5283438590d $ docker inspect -f "{{ .Config.Env }}" f5283438590d
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true] [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
{% endraw %}
## Commit a container with new `CMD` and `EXPOSE` instructions ## Commit a container with new `CMD` and `EXPOSE` instructions

View File

@ -249,6 +249,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Repository` entries separated by a colon for all images: `ID` and `Repository` entries separated by a colon for all images:
{% raw %}
$ docker images --format "{{.ID}}: {{.Repository}}" $ docker images --format "{{.ID}}: {{.Repository}}"
77af4d6b9913: <none> 77af4d6b9913: <none>
b6fa739cedf5: committ b6fa739cedf5: committ
@ -259,10 +260,12 @@ The following example uses a template without headers and outputs the
746b819f315e: postgres 746b819f315e: postgres
746b819f315e: postgres 746b819f315e: postgres
746b819f315e: postgres 746b819f315e: postgres
{% endraw %}
To list all images with their repository and tag in a table format you To list all images with their repository and tag in a table format you
can use: can use:
{% raw %}
$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" $ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID REPOSITORY TAG IMAGE ID REPOSITORY TAG
77af4d6b9913 <none> <none> 77af4d6b9913 <none> <none>
@ -274,3 +277,4 @@ can use:
746b819f315e postgres 9.3 746b819f315e postgres 9.3
746b819f315e postgres 9.3.5 746b819f315e postgres 9.3.5
746b819f315e postgres latest 746b819f315e postgres latest
{% endraw %}

View File

@ -36,29 +36,39 @@ describes all the details of the format.
For the most part, you can pick out any field from the JSON in a fairly For the most part, you can pick out any field from the JSON in a fairly
straightforward manner. straightforward manner.
{% raw %}
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
{% endraw %}
**Get an instance's MAC address:** **Get an instance's MAC address:**
For the most part, you can pick out any field from the JSON in a fairly For the most part, you can pick out any field from the JSON in a fairly
straightforward manner. straightforward manner.
{% raw %}
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
{% endraw %}
**Get an instance's log path:** **Get an instance's log path:**
{% raw %}
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
{% endraw %}
**Get a Task's image name:** **Get a Task's image name:**
{% raw %}
$ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID $ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID
{% endraw %}
**List all port bindings:** **List all port bindings:**
One can loop over arrays and maps in the results to produce simple text One can loop over arrays and maps in the results to produce simple text
output: output:
{% raw %}
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
{% endraw %}
**Find a specific port mapping:** **Find a specific port mapping:**
@ -70,7 +80,9 @@ 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 then `index` 0 contains the first object inside of that. Then we ask for
the `HostPort` field to get the public address. the `HostPort` field to get the public address.
{% raw %}
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
{% endraw %}
**Get a subsection in JSON format:** **Get a subsection in JSON format:**
@ -79,4 +91,6 @@ 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 Docker adds a template function, `json`, which can be applied to get
results in JSON format. results in JSON format.
{% raw %}
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID $ docker inspect --format='{{json .Config}}' $INSTANCE_ID
{% endraw %}

View File

@ -95,8 +95,10 @@ Example output:
} }
] ]
{% raw %}
$ docker node inspect --format '{{ .ManagerStatus.Leader }}' self $ docker node inspect --format '{{ .ManagerStatus.Leader }}' self
false false
{% endraw %}
$ docker node inspect --pretty self $ docker node inspect --pretty self
ID: e216jshn25ckzbvmwlnh5jr3g ID: e216jshn25ckzbvmwlnh5jr3g

View File

@ -275,7 +275,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
The `volume` filter shows only containers that mount a specific volume or have The `volume` filter shows only containers that mount a specific volume or have
a volume mounted in a specific path: a volume mounted in a specific path:
```bash ```bash{% raw %}
$ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}" $ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID MOUNTS CONTAINER ID MOUNTS
9c3527ed70ce remote-volume 9c3527ed70ce remote-volume
@ -283,7 +283,7 @@ CONTAINER ID MOUNTS
$ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}" $ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID MOUNTS CONTAINER ID MOUNTS
9c3527ed70ce remote-volume 9c3527ed70ce remote-volume
``` {% endraw %}```
#### Network #### Network
@ -308,7 +308,9 @@ example shows all containers that are attached to the `net1` network, using
the network id as a filter; the network id as a filter;
```bash ```bash
{% raw %}
$ docker network inspect --format "{{.ID}}" net1 $ docker network inspect --format "{{.ID}}" net1
{% endraw %}
8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5 8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5
@ -337,7 +339,7 @@ Placeholder | Description
`.Size` | Container disk size. `.Size` | Container disk size.
`.Names` | Container names. `.Names` | Container names.
`.Labels` | All labels assigned to the container. `.Labels` | All labels assigned to the container.
`.Label` | Value of a specific label for this container. For example `'{{.Label "com.docker.swarm.cpu"}}'` `.Label` | Value of a specific label for this container. For example `'{% raw %}{{.Label "com.docker.swarm.cpu"}}{% endraw %}'`
`.Mounts` | Names of the volumes mounted in this container. `.Mounts` | Names of the volumes mounted in this container.
When using the `--format` option, the `ps` command will either output the data When using the `--format` option, the `ps` command will either output the data
@ -348,7 +350,9 @@ The following example uses a template without headers and outputs the `ID` and
`Command` entries separated by a colon for all running containers: `Command` entries separated by a colon for all running containers:
```bash ```bash
{% raw %}
$ docker ps --format "{{.ID}}: {{.Command}}" $ docker ps --format "{{.ID}}: {{.Command}}"
{% endraw %}
a87ecb4f327c: /bin/sh -c #(nop) MA a87ecb4f327c: /bin/sh -c #(nop) MA
01946d9d34d8: /bin/sh -c #(nop) MA 01946d9d34d8: /bin/sh -c #(nop) MA
@ -359,7 +363,9 @@ c1d3b0166030: /bin/sh -c yum -y up
To list all running containers with their labels in a table format you can use: To list all running containers with their labels in a table format you can use:
```bash ```bash
{% raw %}
$ docker ps --format "table {{.ID}}\t{{.Labels}}" $ docker ps --format "table {{.ID}}\t{{.Labels}}"
{% endraw %}
CONTAINER ID LABELS CONTAINER ID LABELS
a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd

View File

@ -139,10 +139,10 @@ The `--format` option can be used to obtain specific information about a
service. For example, the following command outputs the number of replicas service. For example, the following command outputs the number of replicas
of the "redis" service. of the "redis" service.
```bash ```bash{% raw %}
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis $ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
10 10
``` {% endraw %}```
## Related information ## Related information

View File

@ -49,10 +49,14 @@ describes all the details of the format.
**Get server version:** **Get server version:**
{% raw %}
$ docker version --format '{{.Server.Version}}' $ docker version --format '{{.Server.Version}}'
1.8.0 1.8.0
{% endraw %}
**Dump raw data:** **Dump raw data:**
{% raw %}
$ docker version --format '{{json .}}' $ docker version --format '{{json .}}'
{"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"},"ServerOK":true,"Server":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","KernelVersion":"3.13.2-gentoo","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"}} {"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"},"ServerOK":true,"Server":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"amd64","KernelVersion":"3.13.2-gentoo","BuildTime":"Tue Jun 23 17:56:00 UTC 2015"}}
{% endraw %}

View File

@ -40,8 +40,10 @@ Example output:
} }
] ]
{% raw %}
$ docker volume inspect --format '{{ .Mountpoint }}' 85bffb0677236974f93955d8ecc4df55ef5070117b0e53333cc1b443777be24d $ docker volume inspect --format '{{ .Mountpoint }}' 85bffb0677236974f93955d8ecc4df55ef5070117b0e53333cc1b443777be24d
/var/lib/docker/volumes/85bffb0677236974f93955d8ecc4df55ef5070117b0e53333cc1b443777be24d/_data /var/lib/docker/volumes/85bffb0677236974f93955d8ecc4df55ef5070117b0e53333cc1b443777be24d/_data
{% endraw %}
## Related information ## Related information

View File

@ -539,13 +539,17 @@ will try forever to restart the container. The number of (attempted) restarts
for a container can be obtained via [`docker inspect`](commandline/inspect.md). For example, to get the number of restarts for a container can be obtained via [`docker inspect`](commandline/inspect.md). For example, to get the number of restarts
for container "my-container"; for container "my-container";
{% raw %}
$ docker inspect -f "{{ .RestartCount }}" my-container $ docker inspect -f "{{ .RestartCount }}" my-container
# 2 # 2
{% endraw %}
Or, to get the last time the container was (re)started; Or, to get the last time the container was (re)started;
{% raw %}
$ docker inspect -f "{{ .State.StartedAt }}" my-container $ docker inspect -f "{{ .State.StartedAt }}" my-container
# 2015-03-04T23:47:07.691840179Z # 2015-03-04T23:47:07.691840179Z
{% endraw %}
Combining `--restart` (restart policy) with the `--rm` (clean up) flag results Combining `--restart` (restart policy) with the `--rm` (clean up) flag results
@ -1402,6 +1406,7 @@ Similarly the operator can set the **hostname** with `-h`.
Example: Example:
{% raw %}
$ docker run --name=test -d \ $ docker run --name=test -d \
--health-cmd='stat /etc/passwd || exit 1' \ --health-cmd='stat /etc/passwd || exit 1' \
--health-interval=2s \ --health-interval=2s \
@ -1446,6 +1451,7 @@ Example:
} }
] ]
} }
{% endraw %}
The health status is also displayed in the `docker ps` output. The health status is also displayed in the `docker ps` output.

View File

@ -166,17 +166,17 @@ for more information.
From the command line, run `docker node inspect <id-node>` to query the nodes. From the command line, run `docker node inspect <id-node>` to query the nodes.
For instance, to query the reachability of the node as a manager: For instance, to query the reachability of the node as a manager:
```bash ```bash{% raw %}
docker node inspect manager1 --format "{{ .ManagerStatus.Reachability }}" docker node inspect manager1 --format "{{ .ManagerStatus.Reachability }}"
reachable reachable
``` {% endraw %}```
To query the status of the node as a worker that accept tasks: To query the status of the node as a worker that accept tasks:
```bash ```bash{% raw %}
docker node inspect manager1 --format "{{ .Status.State }}" docker node inspect manager1 --format "{{ .Status.State }}"
ready ready
``` {% endraw %}```
From those commands, we can see that `manager1` is both at the status From those commands, we can see that `manager1` is both at the status
`reachable` as a manager and `ready` as a worker. `reachable` as a manager and `ready` as a worker.

View File

@ -79,11 +79,11 @@ $ docker service update \
You can use `docker service inspect` to view the service's published port. For You can use `docker service inspect` to view the service's published port. For
instance: instance:
```bash ```bash{% raw %}
$ docker service inspect --format="{{json .Endpoint.Spec.Ports}}" my-web $ docker service inspect --format="{{json .Endpoint.Spec.Ports}}" my-web
[{"Protocol":"tcp","TargetPort":80,"PublishedPort":8080}] [{"Protocol":"tcp","TargetPort":80,"PublishedPort":8080}]
``` {% endraw %}```
The output shows the `<TARGET-PORT>` from the containers and the The output shows the `<TARGET-PORT>` from the containers and the
`<PUBLISHED-PORT>` where nodes listen for requests for the service. `<PUBLISHED-PORT>` where nodes listen for requests for the service.

View File

@ -175,13 +175,13 @@ active tasks.
You can inspect the service to view the virtual IP. For example: You can inspect the service to view the virtual IP. For example:
```bash ```bash{% raw %}
$ docker service inspect \ $ docker service inspect \
--format='{{json .Endpoint.VirtualIPs}}' \ --format='{{json .Endpoint.VirtualIPs}}' \
my-web my-web
[{"NetworkID":"7m2rjx0a97n88wzr4nu8772r3" "Addr":"10.0.0.2/24"}] [{"NetworkID":"7m2rjx0a97n88wzr4nu8772r3" "Addr":"10.0.0.2/24"}]
``` {% endraw %}```
The following example shows how you can add a `busybox` service on the same The following example shows how you can add a `busybox` service on the same
network as the `nginx` service and the busybox service is able to access `nginx` network as the `nginx` service and the busybox service is able to access `nginx`

View File

@ -203,7 +203,9 @@ Launch a container running a PostgreSQL database and pass it the `--network=my-b
If you inspect your `my-bridge-network` you'll see it has a container attached. If you inspect your `my-bridge-network` you'll see it has a container attached.
You can also inspect your container to see where it is connected: You can also inspect your container to see where it is connected:
{% raw %}
$ docker inspect --format='{{json .NetworkSettings.Networks}}' db $ docker inspect --format='{{json .NetworkSettings.Networks}}' db
{% endraw %}
{"my-bridge-network":{"NetworkID":"7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99", {"my-bridge-network":{"NetworkID":"7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99",
"EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.18.0.1","IPAddress":"172.18.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}} "EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.18.0.1","IPAddress":"172.18.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}}
@ -214,14 +216,18 @@ Now, go ahead and start your by now familiar web application. This time leave of
Which network is your `web` application running under? Inspect the application and you'll find it is running in the default `bridge` network. Which network is your `web` application running under? Inspect the application and you'll find it is running in the default `bridge` network.
{% raw %}
$ docker inspect --format='{{json .NetworkSettings.Networks}}' web $ docker inspect --format='{{json .NetworkSettings.Networks}}' web
{% endraw %}
{"bridge":{"NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", {"bridge":{"NetworkID":"7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
"EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}} "EndpointID":"508b170d56b2ac9e4ef86694b0a76a22dd3df1983404f7321da5649645bf7043","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}}
Then, get the IP address of your `web` Then, get the IP address of your `web`
{% raw %}
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web
{% endraw %}
172.17.0.2 172.17.0.2

View File

@ -250,7 +250,9 @@ You can see a sample of that JSON output.
We can also narrow down the information we want to return by requesting a We can also narrow down the information we want to return by requesting a
specific element, for example to return the container's IP address we would: specific element, for example to return the container's IP address we would:
{% raw %}
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nostalgic_morse $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nostalgic_morse
{% endraw %}
172.17.0.5 172.17.0.5

View File

@ -190,7 +190,9 @@ example as:
Next, inspect your linked containers with `docker inspect`: Next, inspect your linked containers with `docker inspect`:
{% raw %}
$ docker inspect -f "{{ .HostConfig.Links }}" web $ docker inspect -f "{{ .HostConfig.Links }}" web
{% endraw %}
[/db:/web/db] [/db:/web/db]

View File

@ -264,15 +264,15 @@ configuration does not change across daemon reload.
Now, inspect the network resources used by `container3`. Now, inspect the network resources used by `container3`.
```bash ```bash{% raw %}
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container3 $ docker inspect --format='{{json .NetworkSettings.Networks}}' container3
{"isolated_nw":{"IPAMConfig":{"IPv4Address":"172.25.3.3"},"NetworkID":"1196a4c5af43a21ae38ef34515b6af19236a3fc48122cf585e3f3054d509679b", {"isolated_nw":{"IPAMConfig":{"IPv4Address":"172.25.3.3"},"NetworkID":"1196a4c5af43a21ae38ef34515b6af19236a3fc48122cf585e3f3054d509679b",
"EndpointID":"dffc7ec2915af58cc827d995e6ebdc897342be0420123277103c40ae35579103","Gateway":"172.25.0.1","IPAddress":"172.25.3.3","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:19:03:03"}} "EndpointID":"dffc7ec2915af58cc827d995e6ebdc897342be0420123277103c40ae35579103","Gateway":"172.25.0.1","IPAddress":"172.25.3.3","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:19:03:03"}}
``` {% endraw %}```
Repeat this command for `container2`. If you have Python installed, you can pretty print the output. Repeat this command for `container2`. If you have Python installed, you can pretty print the output.
```bash ```bash{% raw %}
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool $ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool
{ {
@ -301,7 +301,7 @@ $ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | pyt
"MacAddress": "02:42:ac:19:00:02" "MacAddress": "02:42:ac:19:00:02"
} }
} }
``` {% endraw %}```
You should find `container2` belongs to two networks. The `bridge` network You should find `container2` belongs to two networks. The `bridge` network
which it joined by default when you launched it and the `isolated_nw` which you which it joined by default when you launched it and the `isolated_nw` which you
@ -751,7 +751,7 @@ round-trip min/avg/max = 0.072/0.085/0.101 ms
You can disconnect a container from a network using the `docker network You can disconnect a container from a network using the `docker network
disconnect` command. disconnect` command.
```bash ```bash{% raw %}
$ docker network disconnect isolated_nw container2 $ docker network disconnect isolated_nw container2
$ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool $ docker inspect --format='{{json .NetworkSettings.Networks}}' container2 | python -m json.tool
@ -800,7 +800,7 @@ $ docker network inspect isolated_nw
"Options": {} "Options": {}
} }
] ]
``` {% endraw %}```
Once a container is disconnected from a network, it cannot communicate with Once a container is disconnected from a network, it cannot communicate with
other containers connected to that network. In this example, `container2` can other containers connected to that network. In this example, `container2` can

View File

@ -55,20 +55,25 @@ This is the default usage of `inspect`.
For the most part, you can pick out any field from the JSON in a fairly For the most part, you can pick out any field from the JSON in a fairly
straightforward manner. straightforward manner.
{% raw %}
$ docker-machine inspect --format='{{.Driver.IPAddress}}' dev $ docker-machine inspect --format='{{.Driver.IPAddress}}' dev
192.168.5.99 192.168.5.99
{% endraw %}
**Formatting details:** **Formatting details:**
If you want a subset of information formatted as JSON, you can use the `json` If you want a subset of information formatted as JSON, you can use the `json`
function in the template. function in the template.
{% raw %}
$ docker-machine inspect --format='{{json .Driver}}' dev-fusion $ docker-machine inspect --format='{{json .Driver}}' dev-fusion
{"Boot2DockerURL":"","CPUS":8,"CPUs":8,"CaCertPath":"/Users/hairyhenderson/.docker/machine/certs/ca.pem","DiskSize":20000,"IPAddress":"172.16.62.129","ISO":"/Users/hairyhenderson/.docker/machine/machines/dev-fusion/boot2docker-1.5.0-GH747.iso","MachineName":"dev-fusion","Memory":1024,"PrivateKeyPath":"/Users/hairyhenderson/.docker/machine/certs/ca-key.pem","SSHPort":22,"SSHUser":"docker","SwarmDiscovery":"","SwarmHost":"tcp://0.0.0.0:3376","SwarmMaster":false} {"Boot2DockerURL":"","CPUS":8,"CPUs":8,"CaCertPath":"/Users/hairyhenderson/.docker/machine/certs/ca.pem","DiskSize":20000,"IPAddress":"172.16.62.129","ISO":"/Users/hairyhenderson/.docker/machine/machines/dev-fusion/boot2docker-1.5.0-GH747.iso","MachineName":"dev-fusion","Memory":1024,"PrivateKeyPath":"/Users/hairyhenderson/.docker/machine/certs/ca-key.pem","SSHPort":22,"SSHUser":"docker","SwarmDiscovery":"","SwarmHost":"tcp://0.0.0.0:3376","SwarmMaster":false}
{% endraw %}
While this is usable, it's not very human-readable. For this reason, there is While this is usable, it's not very human-readable. For this reason, there is
`prettyjson`: `prettyjson`:
{% raw %}
$ docker-machine inspect --format='{{prettyjson .Driver}}' dev-fusion $ docker-machine inspect --format='{{prettyjson .Driver}}' dev-fusion
{ {
"Boot2DockerURL": "", "Boot2DockerURL": "",
@ -87,3 +92,4 @@ While this is usable, it's not very human-readable. For this reason, there is
"SwarmHost": "tcp://0.0.0.0:3376", "SwarmHost": "tcp://0.0.0.0:3376",
"SwarmMaster": false "SwarmMaster": false
} }
{% endraw %}

View File

@ -96,13 +96,17 @@ when using the table directive, will include column headers as well.
The following example uses a template without headers and outputs the `Name` and `Driver` entries separated by a colon The following example uses a template without headers and outputs the `Name` and `Driver` entries separated by a colon
for all running machines: for all running machines:
{% raw %}
$ docker-machine ls --format "{{.Name}}: {{.DriverName}}" $ docker-machine ls --format "{{.Name}}: {{.DriverName}}"
default: virtualbox default: virtualbox
ec2: amazonec2 ec2: amazonec2
{% endraw %}
To list all machine names with their driver in a table format you can use: To list all machine names with their driver in a table format you can use:
{% raw %}
$ docker-machine ls --format "table {{.Name}} {{.DriverName}}" $ docker-machine ls --format "table {{.Name}} {{.DriverName}}"
NAME DRIVER NAME DRIVER
default virtualbox default virtualbox
ec2 amazonec2 ec2 amazonec2
{% endraw %}