需要编辑以下条目:
[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:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
在/lib/systemd/system/docker.service
文件中
$ sudo -E systemctl edit docker.service
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock
重启后没有更新服务文件( sudo systemctl restart docker.service
)
编辑服务文件( ) 的推荐方法是什么docker.service
?
答案1
我找到了使用systemctl edit
命令很棘手(使用 Ubuntu 18.04),所以我这样做了:
sudo mkdir /etc/systemd/system/docker.service.d
sudo vi /etc/systemd/system/docker.service.d/override.conf
然后添加我需要的行,在你的情况下:(
是的,显然空的第一ExecStart=
行不是一个错误)
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock
接下来重新加载,重新启动并检查它正在侦听指定的端口:
sudo systemctl daemon-reload
sudo systemctl restart docker.service
sudo netstat -lntp | grep dockerd