下載離線包
下載地址 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.
`
