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

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

当我尝试重新启动docker ..失败
#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])

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

最佳答案

看起来这是从命令行和配置文件合并配置的问题。默认的系统单位文件指定-H fd://,它与您的tcp://0.0.0.0:1234unix:///var/run/docker.sock冲突。

关于此主题,存在许多GitHub问题:

  • https://github.com/moby/moby/issues/22339
  • https://github.com/moby/moby/issues/21559
  • https://github.com/moby/moby/issues/25471
  • https://github.com/moby/moby/pull/27473

  • 他们似乎并不认为这是一个错误。但这绝对是一件烦人的事。一种解决方法是复制默认单位文件并从其中删除-H fd://:
    $ 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
    

    10-08 17:32