更改“主机"/"-h"daemon.json中用于Windows的Docker [英] Change "hosts" / "-h" Docker for Windows in daemon.json

查看:94
本文介绍了更改“主机"/"-h"daemon.json中用于Windows的Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在适用于Windows的Docker桌面上更改 daemon.json (已安装Windows 10 Aniversary最新更新) 1.13.0-rc5 ,这样我就可以像这样更改"hosts":[] 设置:

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守护程序失败并显示消息:无法配置Docker文件C:\ ProgramData \ docker \ config \ daemon.json的守护程序:以下指令既被指定为标志,也被指定为配置文件:hosts:(来自标志:[npipe:////../pipe/docker_engine_windows],来自文件:[tcp://0.0.0.0 http://0.0.0.0] )

看起来该守护进程已经使用 -H 标志启动,并且json配置未与其合并.

Looks like the daemon is already started with -H flag and the json config isn't merged with it.

那么,我们如何通过json文件更改这些设置或更改dockerd启动参数?

So, how can we change those settings by either json file or change the dockerd startup parameters?

推荐答案

您有一个与 issue 22339 :

这是预期的;您不能同时将选项指定为标志和配置文件( daemon.json ).
如果将 DOCKER_OPTS 更改为 DOCKER_OPTS =" 并重新启动,则它应该可以工作.我们明确地不合并"这些配置.

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.

或添加docker.conf

Or add in docker.conf

[Service]
ExecStart=
ExecStart=/path/to/dockerd
# or
ExecStart=/path/to/dockerd daemon

但是官方立场仍然是:

systemd 配置中没有错误,要覆盖 systemd 单位文件中的默认设置,可以使用一个插入文件,如"自定义Docker守护程序选项.

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".

如果同时提供了 daemon.json 中的标志和选项,则会产生错误,这是实现该设计的决定(通常,标志应始终优先于配置文件);自动合并选项不是一个选项,因为这会导致意外的结果(是要覆盖一个选项还是要添加到一个选项?)

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 被拒绝,原因是 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆