下载安装包
在可以连接互联网的机器上下载docker安装包 下载地址 选择一个版本下载后发送到目标服务器
后缀带-ce的是社区版本
安装
解压
解压文件并将文件复制到/user/bin/下
gunzip docker-xxx.tgz && tar -xvf docker-xxx.tar && cp docker/* /user/bin/
创建docker.service文件
cd /etc/systemd/system
vi 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
保存文件并退出,按Esc后输入命令
:wq
启动Docker
chmod +x /etc/systemd/system/docker.service &&\
systemctl daemon-reload &&\
systemctl start docker &&\
systemctl enable docker.service
验证Docker是否安装成功
查看Docker状态
systemctl status docker
查看Docker版本
docker version