docker syslog | how to configure docker to enable syslog

Viewed 21

How can we configure the docker so that the syslog will come in /var/log/messages?

I have tried using docker run --log-driver syslog image but it is not working. I am not able to find /var/log/messages.

1 Answers

Configure syslog for docker.There are two ways, one is global configuration, namely daemon.json, which affects all containers

$ cat /etc/docker/daemon.json
{
   "log-driver": "syslog",
   "log-opts": {
     "tag": "{{.Name}}",
     "syslog-facility": "local6"
   }
}

Another way is per-container configuration. It is to specify parameters when docker run.

$ docker run --log-driver "syslog" --log-opts tag={{.Name}} --log-opts syslog-facility=local6 ...

After this configuration, docker will export the container's log to syslog.

Related