栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1031752.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号