測試服務器:銀河麒麟V10 x86_64
注意:推薦使用國內的鏡像站下載,因為官網不掛梯子無法訪問,我用的是清華大學開源軟件鏡像站
一、下載離線包:
官網下載docker離線包
????下載地址:https://download.docker.com/linux/static/stable/
清華大學docker安裝包
? ?下載地址:https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable
根據自己的操作系統選擇合適的鏡像,如下圖所示:
?我本地的虛擬機是x86_64位的,所以選擇x86_64目錄找到對應的版本下載
?下載完成后,可以放到服務器上,進行安裝操作。
二、執行安裝操作
使用 tar -zxvf?docker-20.10.10.tgz 命令進行解壓操作,解壓后會在當前目錄下生成docker文件
執行如下命令把docker相關文件拷貝到/usr/bin目錄
sudo cp -p docker/* /usr/bin
創建docker.service文件,實現開機自啟動
touch docker.service
然后把如下內容,貼到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
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#################################
把docker.service 拷貝到?/etc/systemd/system/ 目錄。命令如下:
sudo cp docker.service /etc/systemd/system/?
對docker.service設置權限,命令如下:
sudo chmod +x /etc/systemd/system/docker.service
重新加載某個服務的配置文件,命令如下:
sudo systemctl daemon-reload
啟動docker,命令如下:
sudo systemctl start docker
查看是否安裝成功
sudo docker --version