Docker Logging Drivers

A logging driver is a pluggable framework for accessing log data from Docker services and containers.

Default Logging Driver

Set the default logging driver in the “/etc/docker/deamon.json” with the “log-driver” and “log-opts“.

  • local
    • captures output from container’s stdout/stderr and writes them to an internal file-based storage
  • json-file
    • captures output from container’s stdout/stderr and writes them using JSON format
  • journald
    • sends container logs to the system journal. Logs can be retrieved using the “journalctl” command.
  • splunk
    • sends container logs to HTTP Event Collector in Splunk Enterprise and Splunk Cloud.
{
  "log-driver": "local",
  "log-opts": {
    "max-size": "10m"
  }
}
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3",
    "labels": "production_status",
    "env": "os,customer"
  }
}
{
  "log-driver": "journald"
}
{
  "log-driver": "splunk",
  "log-opts": {
    "splunk-token": "",
    "splunk-url": "",
    ...
  }
}

Overriding Logging Driver

You can override the default logging driver for each container by using the “docker run” command with the –log-driver and –log-opt flags.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s