现象
在 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"
}
现在可以正常启动。
发表回复