這篇文章給大家分享的是有關(guān)Linux中如何離線安裝docker的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
成都創(chuàng)新互聯(lián)公司主營武義網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,App定制開發(fā),武義h5小程序定制開發(fā)搭建,武義網(wǎng)站營銷推廣歡迎武義等地區(qū)企業(yè)咨詢
1. 準備docker離線包
docker官方離線包下載地址
下載需要安裝的docker版本,我此次下載的是
docker-17.03.2-ce.tgz版本
2. 準備docker.service 系統(tǒng)配置文件
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
3. 準備安裝腳本和卸載腳本
安裝腳本 install.sh
#!/bin/sh echo '解壓tar包...' tar -xvf $1 echo '將docker目錄移到/usr/bin目錄下...' cp docker/* /usr/bin/ echo '將docker.service 移到/etc/systemd/system/ 目錄...' cp docker.service /etc/systemd/system/ echo '添加文件權(quán)限...' chmod +x /etc/systemd/system/docker.service echo '重新加載配置文件...' systemctl daemon-reload echo '啟動docker...' systemctl start docker echo '設(shè)置開機自啟...' systemctl enable docker.service echo 'docker安裝成功...' docker -v
卸載腳本 uninstall.sh
#!/bin/sh echo '刪除docker.service...' rm -f /etc/systemd/system/docker.service echo '刪除docker文件...' rm -rf /usr/bin/docker* echo '重新加載配置文件' systemctl daemon-reload echo '卸載成功...'
4. 安裝
4.1 此時目錄為:(只需要關(guān)注docker-17.03.2-ce.tgz、docker.service、install.sh、uninstall.sh即可)
4.2 執(zhí)行腳本 sh install.sh docker-17.03.2-ce.tgz
執(zhí)行過程如下:
待腳本執(zhí)行完畢后,執(zhí)行 docker -v
發(fā)現(xiàn)此時docker已安裝成功,可以用 docker --help
查看docker命令,從現(xiàn)在開始你就可以自己安裝image和container了
sh uninstall.sh
4.3 如果你想卸載docker,此時執(zhí)行腳本 sh uninstall.sh
即可,執(zhí)行過程如下:
此時輸入 docker -v
,發(fā)現(xiàn)docker已經(jīng)卸載
感謝各位的閱讀!關(guān)于“Linux中如何離線安裝docker”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!