开机启动Docker-Engine

16

当我重新启动主机时,我希望我的Docker引擎能够在启动时自动启动。

这可能吗? 有人能指点我正确的方向吗?

我的操作系统是RHEL 7.3, 我的/usr/lib/systemd/system/docker.service文件如下:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service

[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
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
Restart=always
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

这个答案可能会有帮助:https://serverfault.com/a/649835/119666 - Ryan
1个回答

40

是的,您可以使用此命令在启动后启用Docker服务的自动启动:

 sudo systemctl enable /usr/lib/systemd/system/docker.service

3
在我的CentOS上,似乎应该是 sudo systemctl enable docker.service - Eric

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接