Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change "hosts" / "-h" Docker for Windows in daemon.json

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?

like image 518
Gutemberg Ribeiro Avatar asked Jan 07 '17 04:01

Gutemberg Ribeiro


People also ask

How do I change Docker daemon configuration?

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.

Where is Docker daemon JSON on Windows?

The configuration file can be found at 'C:\ProgramData\Docker\config\daemon. json'.

Where is Docker 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.


1 Answers

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.

like image 145
VonC Avatar answered Sep 23 '22 01:09

VonC