Skip to content

Commit

Permalink
Document how and why to configure the mode and max-buffer-size lo…
Browse files Browse the repository at this point in the history
…g options.

Documentation based on:
* implementation and comments of the [Ring Logger](https://github.com/moby/moby/blob/master/daemon/logger/ring.go#L49)
* conversation in implementing [PR 28762](moby/moby#28762)
  • Loading branch information
skuenzli committed Dec 24, 2017
1 parent 73c8ff1 commit cf214b5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions engine/admin/logging/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ json-file
{% endraw %}
```

## Manage delivery of log messages from container to log driver

Docker provides two modes for delivering messages from the container to the log driver since Docker 17.04:
1. (default) direct, blocking delivery from container to driver
2. non-blocking delivery that stores log messages in an intermediate per-container ring buffer

The non-blocking mode of message delivery is useful for ensuring that applications will not block when the logging sub-system is unable to keep up with message throughput.

*WARNING*: the oldest messages in memory *will be dropped* when the buffer is full, but this is often preferable to blocking the log-writing process of an application.

The `mode` log option controls whether to use the `blocking` (default) or `non-blocking` message delivery.

When `mode` is set to `non-blocking`, the `max-buffer-size` log option may be used to control the size of the ring buffer used for intermediate message storage. `max-buffer-size` defaults to 1 megabyte.

The following example starts an Alpine container with log output in non-blocking mode and a 4 megabyte buffer:

```bash
$ docker run --log-opt mode=non-blocking --log-opt max-buffer-size=4m alpine sh
```

### Use environment variables or labels with logging drivers

Some logging drivers add the value of a container's `--env|-e` or `--label`
Expand Down

0 comments on commit cf214b5

Please sign in to comment.