docker 启动失败:specified both as a flag and in the configuration fir/daemon.json

由于需要修改docker api 安全漏洞,关闭对外的2375端口。修改 /usr/lib/systemd/system/docker.service 文件启动参数,统一到 /etc/docker/daemon.json 配置

原 docker.service
[Service]
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock  -H tcp://0.0.0.0:2375  -H  unix:///var/run/docker.sock
新 docker.service
[Service]
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
原 daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "data-root":"/home/docker/datadir"
}

新 daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "data-root":"/home/docker/datadir",
  "hosts": ["tcp://127.0.0.1:2375","unix:///var/run/docker.sock"]
}
执行重启docker
[root]$ systemctl daemon-reload && systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

查看日志,提示关键错误 the following directives are specified both as a flag and in the configuration file: hosts

[root]$ journalctl -xe
7月 29 08:24:37 node1 systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has begun starting up.
7月 29 08:24:37 node1 dockerd[32143]: 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 fir/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [fd://], from file: [tcp://127.0.0.1:2375 unix:///var/run/docker.sock])
7月 29 08:24:37 node1 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
7月 29 08:24:37 node1 systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is failed.
7月 29 08:24:37 node1 systemd[1]: Unit docker.service entered failed state.
7月 29 08:24:37 node1 systemd[1]: docker.service failed.

仔细检查配置 docker.service 发现前面还有一个 -H fd:// 迁移配置时删漏了,去掉后服务启动成功

可用 docker.service
[Service]
ExecStart=/usr/bin/dockerd  --containerd=/run/containerd/containerd.sock
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值