[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 --selinux-enabled=false 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 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 # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s
[Install] WantedBy=multi-user.target
给docker.service文件添加执行权限,执行如下命令:
chmod +x /etc/systemd/system/docker.service
启动服务
每次修改docker.service这个文件时都要重新加载下,执行下面命令执行:
systemctl daemon-reload
执行如下命令启动docker:
systemctl start docker
配置开启自启动,执行如下命令:
systemctl enable docker
验证docker是否启动成功
执行如下命令查看docker状态,显示active(running)表示启动成功。
systemctl status docker
执行如下命令,查看版本信息
[root@harbor ~]# docker -v Docker version 18.06.3-ce, build d7080c1