问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/41517970/change-hosts-h-docker-for-windows-in-daemon-json