1. 程式人生 > 其它 >離線安裝Docker並匯入外部映象

離線安裝Docker並匯入外部映象

一、安裝環境 目標伺服器系統:RHEL7.4,Docker離線安裝包版本:20.10.12 二、安裝 1、解壓上傳的壓縮包,解壓後當前路徑會生成一個docker目錄:   tar -zxf docker-20.10.12.tgz 2、將docker服務註冊為service   cp docker/* /usr/bin/   vim /etc/systemd/system/docker.service   將如下內容貼上到docker.service後儲存退出; ps:需要root許可權,如果許可權被限制,可以通過ln -s 軟連線指到/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 # 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 4、啟動 chmod +x /etc/systemd/system/docker.service #新增檔案許可權並啟動docker systemctl daemon-reload #過載unit配置檔案 systemctl start docker #啟動Docker systemctl enable docker.service #設定開機自啟 5、驗證 systemctl status docker #檢視Docker狀態 6、在另一臺Docker伺服器上匯出映象: #映象備份
dockersaveimagename -o /home/路徑/映象名.tar 7、在目標伺服器匯入映象: #還原映象 # docker load --input 映象名.tar