{ "hosts": [ "tcp://0.0.0.0","http://0.0.0.0" ] }
但是,使用设置应用程序更改设置后,我收到此错误:
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])
看起来守护程序已经使用-H标志启动,并且json配置未与它合并.
那么,我们如何通过json文件或更改dockerd启动参数来更改这些设置?
解决方法
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.
或者添加docker.conf
[Service] ExecStart= ExecStart=/path/to/dockerd # or ExecStart=/path/to/dockerd daemon
但官方立场仍然是:
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 “07001”.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?)