環境:centos7
准備:兩台centos7服務器,一台內網一台外網。
目的:要在內網centos7安裝docker
兩種方式安裝:1、內網配置yum進行安裝.2、直接拷貝運行文件進行安裝
方法一:思路
1.在可以連接外網的機器(未安裝過docker,同時跟局域網要安裝docker的機器系統版本一致)通過yum命令將rpm以及相關的依賴下載完成
2.將下載完成的rpm包,拷貝到局域網機器上面
3.構建本地yum源
4.使用yum install docker安裝,安裝完成
外網服務器進行操作
1、下載docker的yum配置
wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -P /etc/yum.repos.d
2、清理yum緩存並緩存
yum clean all yum makecache
3、yum 搜索需要安裝的docker版本
[root@localhost ~]# yum list docker-ce.x86_64 --showduplicates | sort -r * updates: mirrors.aliyun.com Loading mirror speeds from cached hostfile Loaded plugins: fastestmirror * extras: mirrors.aliyun.com docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
。。。。。
4、下載安裝包
mkdir -p /root/docker yum install --downloadonly --downloaddir=/root/docker docker-ce-19.03.9-3.el7 #只下載文件不按裝
5、安裝yum的createrepo命令
yum -y install createrepo [root@localhost docker]# createrepo /root/docker #創建yum的docker數據庫 Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localhost docker]# ls repo* repodata
5、拷貝docker目錄到內網服務器上
下面操作都在內網服務器上操作
6、拷貝文件夾到目錄/data/docker
cat << EOF > /etc/yum.repo/docker-ce.repo [docker-ce] name=Docker-CE baseurl=file:///date/docker enabled=1 gpgcheck=0 EOF
7.輸入yum repolist看是否能看到自己構建的本地源
yum clean all #清除緩存 yum makecache #創建緩存 yum install docker-ce #安裝完成 systemctl start docker && systemctl enable docker #docker 啟動配置開機啟動
方法二:直接拷貝文件到目錄
1、下載文件:
鏈接: https://pan.baidu.com/s/1uE5YskqYlx2y-HmE413KxQ 提取碼: 6puk
2、安裝啟動docker
tar --strip-components=1 -xvzf docker.tgz -C /usr/bin cp docker.service /usr/lib/systemd/system/docker.service systemctl enable docker.service systemctl restart docker.service
