在daemon.json中配置主机后无法启动docker [英] Unable to start docker after configuring hosts in daemon.json

查看:1211
本文介绍了在daemon.json中配置主机后无法启动docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用配置文件 /etc/docker/daemon.json 在ubuntu 16.04中配置docker(版本17.03.1-ce)以添加主机:

I'm trying to configure docker (version 17.03.1-ce) in ubuntu 16.04 using configuration file /etc/docker/daemon.json to add an host:

{
  "debug": true,
  "hosts": ["tcp://0.0.0.0:1234", "unix:///var/run/docker.sock"],
  "dns"  : ["8.8.8.8","8.8.4.4"]
}

当我尝试重新启动docker ..失败

when I try to restart docker.. it fails

#service docker restart
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

监视 systemctl状态docker.service

Starting Docker Application Container Engine...
docker-slave-ubuntu-build dockerd[24806]: unable to configure the Docker daemon with file /etc/docker/daemon.json: 
the following directives are specified both as a flag and in the configuration file: 
hosts: (from flag: [fd://], from file: [tcp://0.0.0.0:4243 unix:///var/run/docker.sock])

在哪里可以删除提到的标志?我必须修改维护者的脚本吗?

Where I can remove the mentioned flag ? I have to modify maintainer's script ?

推荐答案

对于systemd,我的首选方法是部署一个简单的覆盖文件(您可能需要先创建目录): / p>

For systemd, my preferred method is to deploy a simple override file (you may need to first create the directory):

$ cat /etc/systemd/system/docker.service.d/override.conf
# Disable flags to dockerd, all settings are done in /etc/docker/daemon.json
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd

这将从dockerd中删除 -H ... 默认标志以及其他任何选项,并让您可以通过daemon.json文件管理docker。只要他们不修改ExecStart,这还使Docker可以对其启动脚本进行更改,并且您将继续接收这些更改而无需维护自己的docker.service副本。

This removes the -H ... default flag from dockerd along with any other options and lets you manage docker from the daemon.json file. This also allows docker to make changes to their startup scripts as long as they don't modify the ExecStart and you'll continue to receive those changes without maintaining your own copy of the docker.service.

创建此文件后,运行 systemctl daemon-reload; systemctl重新启动docker

这篇关于在daemon.json中配置主机后无法启动docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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