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

查看:255
本文介绍了在 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 status 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 单元文件指定 -H fd:// 并且它与您的 tcp://0.0.0.0:1234unix:///冲突var/run/docker.sock.

It looks like this is an issue merging configuration from both the command line and configuration file. The default systemd unit file is specifying -H fd:// and it conflicts with your tcp://0.0.0.0:1234 and unix:///var/run/docker.sock.

关于这个主题有许多 GitHub 问题:

There are a number of GitHub issues on the subject:

他们似乎并不认为这是一个错误.但这绝对是一个烦恼.解决方法是复制默认单元文件并从中删除 -H fd:// :

They don't seem to consider this a bug. But it is definitely an annoyance. A workaround is to copy the default unit file and remove the -H fd:// from it:

$ sudo cp /lib/systemd/system/docker.service /etc/systemd/system/
$ sudo sed -i 's/ -H fd:////g' /etc/systemd/system/docker.service
$ sudo systemctl daemon-reload
$ sudo service docker restart

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

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