docker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docker [2020/04/15 00:46] tmaierdocker [2022/01/31 11:28] (current) tmaier
Line 61: Line 61:
 </code> </code>
  
 +
 +===== Docker Logging =====
 +====== Logging with rsyslog ======
 +/etc/rsyslog.d/docker.conf
 +<code>
 +# Docker config
 +$AddUnixListenSocket /tmp/syslog.sock
 +
 +# syslogtag enthält noch PID
 +# programname nur appname/tag: 598-rddnsmasq
 +$template myFormat,"%timereported% %programname%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
 +
 +template(
 +  name="docker_container_file"
 +  type="string"
 +  string="/var/log/docker/%programname%.log"
 +  option.casesensitive="on"
 +)
 +
 +# 23: local7
 +if $syslogfacility == 23 then {
 +  if $programname startswith "bw_" then {
 +    action(name="docker-containers-bitwarden" type="omfile" file="/var/log/docker/bitwarden.log" template="myFormat")
 +  } else {
 +    action(name="docker-containers" type="omfile" dynaFile="docker_container_file" template="myFormat")
 +  }
 +}
 +</code>
 +
 +/etc/docker/daemon.json
 +<code>
 +{
 +  "log-driver": "syslog",
 +  "log-opts":
 +    {
 +      "tag": "{{.Name}}",
 +      "syslog-facility": "local7",
 +      "syslog-address": "unixgram:///tmp/syslog.sock"
 +    }
 +}
 +</code>
 +
 +Restart rsyslog, the docker daemon and then all containers to switch to the new driver. Otherwise the docker daemon shows the following error message for the affected containers: "Configured log driver does not support reads, enabling local file cache for container logs".
  • docker.1586904393.txt.gz
  • Last modified: 2020/12/29 02:09
  • (external edit)