dockerdocker-compose

Docker-compose not reading logging config in /etc/docker/daemon.json


I've got a daemon.json file, stored in /etc/docker/daemon.json. to configure the docker daemon with following contents:

{
  "log-driver" : "syslog",
  "log-opts": {
     "syslog-facility": "local1",
     "tag": "{{.Name}}"
  },
  "storage-driver": "devicemapper",
  "storage-opts": [
     "dm.fs=xfs",
     "dm.thinpooldev=/dev/mapper/vg00-docker--pool",
     "dm.use_deferred_removal=true"
  ]
}

None of the docker-compose services have logging options configured, nor are any of the docker containers configured to start with --log-driver in their cmd or entrypoint.

Inspecting the output of the docker info command, I can verify that the logging driver is set to syslog.

However when running a docker-compose stack, all of the containers still show json-file upon inspecting them with the command docker inspect --format='{{.HostConfig.LogConfig.Type}}' , which seems to me as if docker-compose is not respecting the /etc/docker/daemon.json config file, just for the logging config, as the storage-driver is set correctly.

The docker version I used to run this is 17.12.0, docker-compose is at 1.19.0


Solution

  • /etc/docker/daemon.json is default config file and docker daemon should access if exists when starts. Maybe there's something wrong in your file according to the configuration (because it looks ok according to syntax).

    Let's try to force config-file read with debug enabled and see which error it shows.

    /usr/bin/dockerd stop
    /usr/bin/dockerd -D -l debug --config-file /etc/docker/daemon.json
    

    After that, you can see logs with journalctl -u docker

    Alternatively, you know that you can test easily each config param passing them one by one via cli instead json config file, in order to figure out which of them causes that configuration is not load.

    /usr/bin/dockerd stop
    /usr/bin/dockerd -D -l debug --log-driver syslog --storage-driver devicemapper ...
    

    Adding one by one you will be able to check if for example it fails with storage-opts because /dev/mapper/vg00-docker--pool is not mounted or whatever.