Search code examples
dockerloggingrsyslog

Docker Service not starting when trying to set max-size in /etc/docker/daemon.json


The docker service does not seem to recognize the max-size log-opts setting in the daemon.json file and thus fails to start.

/etc/docker/daemon.json

{
    "log-driver": "syslog",
    "log-opts": {
        "tag": "docker/{{.Name}}",
        "syslog-address": "unixgram:///dev/log",
        "max-size": "1g",
        "max-file": "3"
    }
}

Output when attempting to start the docker in debug

sudo dockerd --debug

INFO[2024-01-08T21:26:17.680158874Z] Starting up
DEBU[2024-01-08T21:26:17.680948989Z] Listener created for HTTP on unix (/var/run/docker.sock)
DEBU[2024-01-08T21:26:17.682318614Z] Golang's threads limit set to 56700
DEBU[2024-01-08T21:26:17.682822324Z] metrics API listening on /var/run/docker/metrics.sock
DEBU[2024-01-08T21:26:17.691143680Z] processing event stream                       module=libcontainerd namespace=plugins.moby
DEBU[2024-01-08T21:26:17.691567388Z] Cleaning up old mountid : start.
failed to start daemon: failed to set log opts: unknown log opt 'max-size' for syslog log driver

Not sure what i could be missing here, as this is a valid flag according to the logging driver doc, Configure logging drivers

Docker version 24.0.7, build afdd53b

Removing the "max-size" and "max-file" key value pairs from the daemon.json file works just fine and docker is able to start normally.


Solution

  • Options are specific to each driver, and that option does not exist for the syslog driver: https://docs.docker.com/config/containers/logging/syslog/#options

    That option is supported in the local and json-file driver.