I'm trying to change daemon.json
on Docker Desktop for Windows (Windows 10 Aniversary latest updates installed) 1.13.0-rc5
so I can change the "hosts": []
setting like this:
{
"hosts": [
"tcp://0.0.0.0",
"http://0.0.0.0"
]
}
However, after change the settings using the settings app I got this error:
Docker daemon failed with message: unable to configure the Docker daemon with file C:\ProgramData\docker\config\daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [npipe:////./pipe/docker_engine_windows], from file: [tcp://0.0.0.0 http://0.0.0.0])
Looks like the daemon is already started with -H
flag and the json config isn't merged with it.
So, how can we change those settings by either json file or change the dockerd startup parameters?
To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon.json on Linux systems, or C:\ProgramData\docker\config\daemon.json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced. You can also start the Docker daemon manually and configure it using flags.
The configuration file can be found at 'C:\ProgramData\Docker\config\daemon. json'.
Edit the daemon. json file, which is usually located in /etc/docker/. You may need to create this file, if it does not yet exist. On macOS or Windows, do not edit the file directly.
You have a similar case with issue 22339:
This is expected; you cannot specify options both as a flag and in the configuration file (
daemon.json
).
If you change yourDOCKER_OPTS
toDOCKER_OPTS=""
and restart, then it should work. We explicitly don't "merge" these configurations.
Or add in docker.conf
[Service]
ExecStart=
ExecStart=/path/to/dockerd
# or
ExecStart=/path/to/dockerd daemon
But the official stance remains:
There's no bug in the
systemd
configuration, to override defaults in asystemd
unit file, you can use a drop-in file, as described in "Custom Docker daemon options".Producing an error if both a flag and an option in
daemon.json
are provided was a design decision when implementing that (in general, flags should always have precedence over configuration files); automatically merging options was not an option, as this would lead to unexpected results (was the intent to override an option, or to add to an option?)
PR 27473 was rejected, for issue 21559.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With