前言
有時(shí)候會(huì)遇到服務(wù)器不能聯(lián)網(wǎng)的情況,這樣就沒法用yum安裝軟件,docker也是如此,針對(duì)這種情況,總結(jié)了一下離線安裝docker的步驟,分享給大家
1. 準(zhǔn)備docker離線包
docker官方離線包下載地址
下載需要安裝的docker版本,我此次下載的是
docker-17.03.2-ce.tgz版本
2. 準(zhǔn)備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. 準(zhǔn)備安裝腳本和卸載腳本
安裝腳本 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 '啟動(dòng)docker...' systemctl start docker echo '設(shè)置開機(jī)自啟...' 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 此時(shí)目錄為:(只需要關(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)此時(shí)docker已安裝成功,可以用 docker --help
查看docker命令,從現(xiàn)在開始你就可以自己安裝image和container了
sh uninstall.sh
4.3 如果你想卸載docker,此時(shí)執(zhí)行腳本 sh uninstall.sh
即可,執(zhí)行過程如下:
此時(shí)輸入 docker -v
,發(fā)現(xiàn)docker已經(jīng)卸載
總結(jié)
以上所述是小編給大家介紹的Linux 離線安裝docker的過程(一鍵式安裝),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
標(biāo)簽:淮安 福州 上海 鷹潭 泰安 安康 樂山 德宏
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux 離線安裝docker的過程(一鍵式安裝)》,本文關(guān)鍵詞 Linux,離線,安裝,docker,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。