简体   繁体   English

在daemon.json中为Windows更改“ hosts” /“-h” Docker for Windows

[英]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: 我正在尝试在Windows的Docker桌面上更改daemon.json (已安装Windows 10 Aniversary最新更新) 1.13.0-rc5以便可以更改"hosts": []设置,如下所示:

{
  "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] ) Docker守护程序失败,并显示以下消息:无法使用文件C:\\ ProgramData \\ docker \\ config \\ daemon.json配置Docker守护程序:以下指令同时被指定为标志和配置文件:hosts:(from标志:[npipe :////./pipe/docker_engine_windows],来自文件:[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. 看起来守护进程已经以-H标志启动,并且json配置未与它合并。

So, how can we change those settings by either json file or change the dockerd startup parameters? 那么,如何通过json文件更改这些设置或更改dockerd启动参数?

You have a similar case with issue 22339 : 您也有类似的情况, 问题22339

This is expected; 这是预期的; you cannot specify options both as a flag and in the configuration file ( daemon.json ). 您不能同时将选项指定为标志和配置文件( daemon.json )。
If you change your DOCKER_OPTS to DOCKER_OPTS="" and restart, then it should work. 如果将DOCKER_OPTS更改为DOCKER_OPTS=""并重新启动,则它应该可以工作。 We explicitly don't "merge" these configurations. 我们明确地不“合并”这些配置。

Or add in docker.conf 或添加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 ". systemd配置中没有错误,要覆盖systemd单位文件中的默认设置,可以使用一个插入文件,如“ 自定义Docker守护程序选项 ”中所述。

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); 如果同时提供daemon.json中的标志和选项, daemon.json产生错误,这是实现该标志时的设计决定(通常,标志应始终优先于配置文件); 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 . PR 27473被拒绝, 发行号为21559

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM