mirror of https://github.com/docker/docs.git
				
				
				
			Fixing double curly braces
This commit is contained in:
		
							parent
							
								
									132f33de6f
								
							
						
					
					
						commit
						46e044ec59
					
				| 
						 | 
					@ -22,41 +22,51 @@ list of elements they support in their templates:
 | 
				
			||||||
Docker provides a set of basic functions to manipulate template elements.
 | 
					Docker provides a set of basic functions to manipulate template elements.
 | 
				
			||||||
This is the complete list of the available functions with examples:
 | 
					This is the complete list of the available functions with examples:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Join
 | 
					### `join`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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.
 | 
				
			||||||
 | 
					 | 
				
			||||||
	$ docker inspect --format '{{json .Mounts}}' container
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Lower
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Lower turns a string into its lower case representation.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	$ docker inspect --format "{{lower .Name}}" container
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Split
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Split slices a string into a list of strings separated by a separator.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{% raw %}
 | 
						{% raw %}
 | 
				
			||||||
	# docker inspect --format '{{split (join .Names "/") "/"}}' container
 | 
						$ docker inspect --format '{{json .Mounts}}' container
 | 
				
			||||||
    {% endraw %}
 | 
						{% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Title
 | 
					### `lower`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Title capitalizes a string.
 | 
					`lower` transforms a string into its lowercase representation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{% raw %}
 | 
				
			||||||
 | 
						$ docker inspect --format "{{lower .Name}}" container
 | 
				
			||||||
 | 
						{% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `split`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`split` slices a string into a list of strings separated by a separator.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{% raw %}
 | 
				
			||||||
 | 
						$ docker inspect --format '{{split (join .Names "/") "/"}}' container
 | 
				
			||||||
 | 
					  {% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `title`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`title` capitalizes the first character of a string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{% raw %}
 | 
				
			||||||
	$ docker inspect --format "{{title .Name}}" container
 | 
						$ docker inspect --format "{{title .Name}}" container
 | 
				
			||||||
 | 
						{% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Upper
 | 
					### `upper`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Upper turms a string into its upper case representation.
 | 
					`upper` transforms a string into its uppercase representation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{% raw %}
 | 
				
			||||||
	$ docker inspect --format "{{upper .Name}}" container
 | 
						$ docker inspect --format "{{upper .Name}}" container
 | 
				
			||||||
 | 
						{% endraw %}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ 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:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 - `fluentd-address`: specify a socket address to connect to the Fluentd daemon, ex `fluentdhost:24224` or `unix:///path/to/fluentd.sock`
 | 
					 - `fluentd-address`: specify a socket address to connect to the Fluentd daemon, ex `fluentdhost:24224` or `unix:///path/to/fluentd.sock`
 | 
				
			||||||
 - `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 {% raw %}`{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}`{% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Configure the default logging driver by passing the
 | 
					Configure the default logging driver by passing the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,12 +10,13 @@ The `tag` log option specifies how to format a tag that identifies the
 | 
				
			||||||
container's log messages. By default, the system uses the first 12 characters of
 | 
					container's log messages. By default, the system uses the first 12 characters of
 | 
				
			||||||
the container id. To override this behavior, specify a `tag` option:
 | 
					the container id. To override this behavior, specify a `tag` option:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```bash
 | 
				
			||||||
docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 --log-opt tag="mailer"
 | 
					$ docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 --log-opt tag="mailer"
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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.         |
 | 
				
			||||||
| 
						 | 
					@ -26,13 +27,15 @@ Docker supports some special template markup you can use when specifying a tag's
 | 
				
			||||||
| `{{.ImageName}}`   | The name of the image used by the container.         |
 | 
					| `{{.ImageName}}`   | The name of the image used by the container.         |
 | 
				
			||||||
| `{{.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:
 | 
					{% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					For example, specifying a {% raw %}`--log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"`{% endraw %} value yields `syslog` log lines like:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```none
 | 
				
			||||||
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.
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
At startup time, the system sets the `container_name` field and `{{.Name}}` in
 | 
					At startup time, the system sets the `container_name` field and {% raw %}`{{.Name}}`{% endraw %} 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.
 | 
				
			||||||
| 
						 | 
					@ -41,20 +44,21 @@ 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
 | 
				
			||||||
context](https://github.com/docker/docker/blob/master/daemon/logger/context.go).
 | 
					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, if you use the following
 | 
				
			||||||
 | 
					command, you get the output that follows:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```bash
 | 
				
			||||||
 | 
					{% 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:
 | 
					```none
 | 
				
			||||||
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
Apr  1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: + exec app
 | 
					Apr  1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: + exec app
 | 
				
			||||||
Apr  1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: 2016-04-01 15:22:17.075416751 +0000 UTC stderr msg: 1
 | 
					Apr  1 15:22:17 ip-10-27-39-73 docker/logtester.1234[45499]: 2016-04-01 15:22:17.075416751 +0000 UTC stderr msg: 1
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ logging driver options:
 | 
				
			||||||
| `splunk-verify-connection`  | optional | Verify on start, that docker can connect to Splunk server. Defaults to true.                                                                                                                                            |
 | 
					| `splunk-verify-connection`  | optional | Verify on start, that docker can connect to Splunk server. Defaults to true.                                                                                                                                            |
 | 
				
			||||||
| `splunk-gzip`               | optional | Enable/disable gzip compression to send events to Splunk Enterprise or Splunk Cloud instance. Defaults to false.                                                                                                         |
 | 
					| `splunk-gzip`               | optional | Enable/disable gzip compression to send events to Splunk Enterprise or Splunk Cloud instance. Defaults to false.                                                                                                         |
 | 
				
			||||||
| `splunk-gzip-level`         | optional | Set compression level for gzip. Valid values are -1 (default), 0 (no compression), 1 (best speed) ... 9 (best compression). Defaults to [DefaultCompression](https://golang.org/pkg/compress/gzip/#DefaultCompression). |
 | 
					| `splunk-gzip-level`         | optional | Set compression level for gzip. Valid values are -1 (default), 0 (no compression), 1 (best speed) ... 9 (best compression). Defaults to [DefaultCompression](https://golang.org/pkg/compress/gzip/#DefaultCompression). |
 | 
				
			||||||
| `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 {% raw %}`{{.ID}}`{% endraw %} (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.                                                                             |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ $ docker run --log-driver=splunk \
 | 
				
			||||||
By default Logging Driver sends messages as `inline` format, where each message
 | 
					By default Logging Driver sends messages as `inline` format, where each message
 | 
				
			||||||
will be embedded as a string, for example
 | 
					will be embedded as a string, for example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```none
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "attrs": {
 | 
					    "attrs": {
 | 
				
			||||||
        "env1": "val1",
 | 
					        "env1": "val1",
 | 
				
			||||||
| 
						 | 
					@ -102,7 +102,7 @@ will try to parse every line as a JSON object and send it as embedded object. In
 | 
				
			||||||
case if it cannot parse it - message will be send as `inline`. For example
 | 
					case if it cannot parse it - message will be send as `inline`. For example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```none
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "attrs": {
 | 
					    "attrs": {
 | 
				
			||||||
        "env1": "val1",
 | 
					        "env1": "val1",
 | 
				
			||||||
| 
						 | 
					@ -129,7 +129,7 @@ Third format is a `raw` message. You can specify it by using
 | 
				
			||||||
`--log-opt splunk-format=raw`. Attributes (environment variables and labels) and
 | 
					`--log-opt splunk-format=raw`. Attributes (environment variables and labels) and
 | 
				
			||||||
tag will be prefixed to the message. For example
 | 
					tag will be prefixed to the message. For example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```none
 | 
				
			||||||
MyImage/MyContainer env1=val1 label1=label1 my message
 | 
					MyImage/MyContainer env1=val1 label1=label1 my message
 | 
				
			||||||
MyImage/MyContainer env1=val1 label1=label1 {"foo": "bar"}
 | 
					MyImage/MyContainer env1=val1 label1=label1 {"foo": "bar"}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -177,15 +177,19 @@ 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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,7 +144,9 @@ Launch a container running a PostgreSQL database and pass it the `--net=my-bridg
 | 
				
			||||||
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"}}
 | 
				
			||||||
| 
						 | 
					@ -155,14 +157,18 @@ Now, go ahead and start your by now familiar web application. This time don't sp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -191,9 +191,11 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [/db:/web/db]
 | 
					    [/db:/web/db]
 | 
				
			||||||
 | 
					    {% endraw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You can see that the `web` container is now linked to the `db` container
 | 
					You can see that the `web` container is now linked to the `db` container
 | 
				
			||||||
`web/db`. Which allows it to access information about the `db` container.
 | 
					`web/db`. Which allows it to access information about the `db` container.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue