docker修改daemon.json hosts报错

12 篇文章 0 订阅

背景

	centos7

场景

在  /etc/docker/daemon.json 添加如下代码:
{
  "registry-mirrors": ["https://qgm5dyuu.mirror.aliyuncs.com","https://registry.docker-cn.com"],
  "bip": "10.0.0.1/16",
  "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}

错误

	 启动不起来,错误代码
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl status docker.service 
?.docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2020-11-03 15:09:17 CST; 50s ago
     Docs: https://docs.docker.com
  Process: 40602 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 40602 (code=exited, status=1/FAILURE)

Nov 03 15:09:15 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: Failed to start Docker Application Container Engine.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Service RestartSec=2s expired, scheduling restart.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: Stopped Docker Application Container Engine.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Start request repeated too quickly.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 03 15:09:17 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: Failed to start Docker Application Container Engine.
Nov 03 15:09:18 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Start request repeated too quickly.
Nov 03 15:09:18 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 03 15:09:18 iZ8vbi4t4rsi4lb9e7bkckZ systemd[1]: Failed to start Docker Application Container Engine.

原因

docker 的 socket 配置hosts出现了冲突

解决办法

vi	/usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
修改为ExecStart=/usr/bin/dockerd

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

使之生效

systemctl daemon-reload

重新启动docker即可

systemctl start docker
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值