Where's docker's daemon.json? (missing) Where's docker's daemon.json? (missing) docker docker

Where's docker's daemon.json? (missing)


The default config file path on Linux is /etc/docker/daemon.json like you said, but it doesn't exist by default. You can write one yourself and put additional docker daemon configuration stuff in there instead of passing in those configuration options into the command line. You don't even have to do dockerd --config-file /etc/docker/daemon.json since that's the default path, but it can be useful to make it explicit for others who are inspecting the system.

Also ensure that any configuration you set in /etc/docker/daemon.json doesn't conflict with options passed into the command line evocation of dockerd. For reference:

The options set in the configuration file must not conflict with options set via flags. The docker daemon fails to start if an option is duplicated between the file and the flags, regardless their value.


Based on @huu answer I searched for the specific reference in the docs.

Notice the sentences in bold below.


Reference 1: From the Configure the Docker daemon section:

There are two ways to configure the Docker daemon:

  • Use a JSON configuration file. This is the preferred option, since itkeeps all configurations in a single place.

  • Use flags when startingdockerd. You can use both of these options together as long as youdon’t specify the same option both as a flag and in the JSON file. Ifthat happens, the Docker daemon won’t start and prints an errormessage.

To configure the Docker daemon using a JSON file, create a file at/etc/docker/daemon.json on Linux systems, orC:\ProgramData\docker\config\daemon.json on Windows. On MacOS go tothe whale in the taskbar > Preferences > Daemon > Advanced.


Reference 2: From the Enable debugging section

There are two ways to enable debugging. The recommended approach is toset the debug key to true in the daemon.json file. This method worksfor every Docker platform.

  1. Edit the daemon.json file, which is usually located in /etc/docker/. You may need to create this file, if it does not yetexist. On macOS or Windows, do not edit the file directly. Instead,go to Preferences / Daemon / Advanced.

  2. ....


If you have installed Docker as part of installation of Ubuntu, then Docker is installed as a snap.

The config can be found in /var/snap/docker/current/config/daemon.json.

Refer to https://github.com/docker-archive/docker-snap/issues/22#issuecomment-423361607

Summary:

anonymouse64 commented on 21 Sep 2018Modifying the daemon.json file is now supported in the version of the snapI have published in the edge channel. The daemon is now hard-coded to readthe config file for it's settings, so you can now edit the daemon.jsonlocated in $SNAP_DATA/config/daemon.json (on Ubuntu for example $SNAP_DATAis /var/snap/docker/current, it may be different on your distribution) andthen restart docker for the changes to take effect with:sudo snap restart dockerYou may switch the snap to the edge channel to test this by running:sudo snap refresh docker --edgeThe changes in the edge channel should show up in stable in a short whileif you don't wish to use edge.

This now seems to be present in 'stable'. I am using Ubunu 20.04 and I found daemon.json in /var/snap/docker/current/config/daemon.json.

I changed the 'log-driver' to 'local' and this was picked up by docker after restarting it:

docker info --format '{{.LoggingDriver}}'json-filenano /var/snap/docker/current/config/daemon.json    # added line:  "log-driver":"local",snap restart dockerdocker info --format '{{.LoggingDriver}}'local