准备安装包
官网下载二进制安装包Index of linux/static/stable/x86_64/
安装
1、上传二进制包到服务器
2、解压
3、将二进制文件移动到可执行文件上的目录路径
4、进入/etc/systemd/system/ (必须先进入该目录才能新增docker.service)并新增docker.service,代码如下
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[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
5.给docker.service文件添加执行权限
chmod +x /etc/systemd/system/docker.service
6.重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload
7.启动docker
systemctl start docker
8、设置开机自启动
9、测试是否安装成功
systemctl status docker