Docker Sidecar Logging

Alex Rhea
Alex’s Blog
Published in
1 min readDec 22, 2016

Logging with Docker can be tricky, and often times there are constraints around where logs can be sent. Especially in an enterprise environment, popular logging providers may not be a possibility. Not to mention, configuring logging at the daemon level isn’t supported by all of the Docker tools and products, which can throw a major monkey wrench into your plans. The sidecar approach side steps all of these issues by running just like another container on the machine and forwarding the logs to the destination of your choosing. In this post I am going to focus on syslog, but this can also be translated to other formats if necessary.

Configuring the Daemon

So I know what you are thinking, I thought this was the sidecar approach. Since, we are forwarding our logs we need to put limits on the json-file logs locally as to not overflow the machine. You will need to add the follow configuration to your Docker daemon configuration method. Feel free to adjust any of the following settings to meet your needs.

Configuring Logspout

Logspout is from Gliderlabs, it forwards the logs from the host to a central source. Below is the default syslog implementation, it will also restart if the container loses connection and on system restarts.

In a later post I will discuss how to setup Logstash as a centralized log forwarder to an external service.

--

--