下载离线包
下载地址 https://download.docker.com/linux/static/stable/x86_64/
```
[root@localhost docker]# wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz
```
解压压缩包
```
[root@localhost docker]# tar -xvf docker-20.10.0.tgz
```
安装
移动到/user/bin/目录下
```[root@localhost docker]# cp docker/* /usr/bin
```
将docker注册为服务
```
[root@localhost etc]# cat /etc/systemd/system/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
ExecStart=/usr/bin/dockerd --graph=/docker -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
```
启动服务
添加执行权限
```
[root@localhost etc]# chmod +x /etc/systemd/system/docker.service
```
加载配置文件
```
[root@localhost etc]# systemctl daemon-reload
```
启动服务
```
[root@localhost etc]# systemctl start docker
```
查看状态
```
[root@localhost etc]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2022-01-21 10:42:08 CST; 36s ago
Docs: https://docs.docker.com
Main PID: 13295 (dockerd)
Tasks: 28
Memory: 38.8M
```
设置开机自启
```
[root@localhost etc]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
```