官方支持的日志驱动

更新于 2018年07月06日14:42:03
Driver Description
none No logs will be available for the container and docker logs will not return any output.
命令 docker logs 也看不到任何东西
json-file The logs are formatted as JSON. The default logging driver for Docker.
默认驱动,/var/lib/docker/containers/ 目录下以 json 形式保存
syslog Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.
写到 syslog 里
journald Writes log messages to journald. The journald daemon must be running on the host machine.
日志发送到journald (systemd)
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
以 gelf(Graylog Extended Log Format) 发送日志
fluentd Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.
日志发送给 fluented
awslogs Writes log messages to Amazon CloudWatch Logs.
日志发送 Amazon CloudWatch Logs
splunk Writes log messages to splunk using the HTTP Event Collector.
日志发送给 splunk
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
日志发送给 Event Tracing for Windows
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
日志发送给 Google 日志系统
logentries Writes log messages to Rapid7 Logentries.
日志发送给 nats

docker-compose.yml 示例

json-file

  1. logging:
  2. driver: json-file
  3. options:
  4. max-file: '3'
  5. max-size: '10m'

fluentd

  1. logging:
  2. driver: fluentd
  3. options:
  4. fluentd-address: localhost:24224
  5. tag: container_a

gelf

  1. logging:
  2. driver: gelf
  3. options:
  4. gelf-address: udp://localhost:12201
  5. tag: container_b