Zxilly
Try to be 1%
Zxilly's Blog

Docker 避免启动参数与配置文件冲突

现象

daemon.json 中设置 hosts 后,启动 Docker 显示

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: [unix:///var/run/docker.sock tcp://0.0.0.0:2376])

原因

安装 Docker-ce 后, systemd 默认的启动参数是 /usr/bin/dockerd -H fd://, 与配置文件冲突

解决方案

mkdir /etc/systemd/system/docker.service.d/
vi /etc/systemd/system/docker.service.d/docker.conf

写入

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd

覆盖 systemd 的默认启动命令。

daemon.json

{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com"
    ],
    "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
    "tlsverify": true,
    "tlscacert": "/root/ssl/ca.pem",
    "tlscert": "/root/ssl/server-cert.pem",
    "tlskey": "/root/ssl/server-key.pem"
}

现在可以正常启动。

# #
首页      代码      Docker 避免启动参数与配置文件冲突

Zxilly

文章作者

发表回复

textsms
account_circle
email

Zxilly's Blog

Docker 避免启动参数与配置文件冲突
现象 在 daemon.json 中设置 hosts 后,启动 Docker 显示 unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as …
扫描二维码继续阅读
2022-04-26