• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

docker - 在 daemon.json 中配置主机后无法启动 docker

[复制链接]
菜鸟教程小白 发表于 2022-8-3 10:11:28 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试使用配置文件/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])

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



Best Answer-推荐答案


看起来这是从命令行和配置文件合并配置的问题。默认的 systemd 单元文件指定 -H fd://它与您的 tcp://0.0.0.0:1234 冲突和 unix:///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
    

    关于docker - 在 daemon.json 中配置主机后无法启动 docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44052054/

    回复

    使用道具 举报

    懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关注0

    粉丝2

    帖子830918

    发布主题
    阅读排行 更多
    广告位

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap