8

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?

veben
  • 19,637
  • 14
  • 60
  • 80
Gutemberg Ribeiro
  • 1,533
  • 1
  • 21
  • 45

1 Answers1

2

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 your DOCKER_OPTS to DOCKER_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 a systemd 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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for reply. I saw that pr/issue as well. However, I'm on Windows. How can I change he default dockerd prameters so I can add the -H there instead of in the file? – Gutemberg Ribeiro Jan 07 '17 at 15:44
  • 1
    I'm also looking for this - pretty annoying that Docker for Windows seems to start the service with the -H flag. Seems like putting this as a default into the daemon.json would have worked instead? – Josh Wittner May 04 '17 at 23:15
  • Not just a windows thing. On a ubuntu 16.04 box, which ships with systemd, the daemon is started with command line options `-H fd://`, which conflicts with any host setting in daemon.json. If you then try to naively create a systemd override file to change the `ExecStart` directive (i.e. with `systemctl edit docker`), then systemctl complains that the `Service has more than one ExecStart setting`. The fix then is to, counterintuitively, add an empty `ExecStart=`, followed by the new setting `ExecStart=/usr/bin/dockerd`. See: [Issue 14491](https://github.com/moby/moby/issues/14491). not fun. – init_js Dec 04 '18 at 19:32