centos7 局域网环境下搭建yum离线安装docker

step 1 下载所需的依赖包

在一台外网的电脑上操作
[root@localhost] yum install --downloadonly --downloaddir=/data/centos7repo -y yum-utils device-mapper-persistent-data lvm2 &&
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo &&
yum install --downloadonly --downloaddir=/data/centos7repo -y docker-ce-17.12.1.ce

step 2 建立索引

[root@localhost]# cd /data/centos7repo
[root@localhost]# createrepo ./

step 3 安装httpd并配置

[root@localhost]# yum install httpd -y && systemctl start httpd
[root@localhost]# ln -s /var/www/html/centos7 /data/centos7repo/

step 4 配置yum

[root@dockerhome data]# cat /etc/yum.repos.d/CentOS-Base.repo
#CentOS-Base.repo

#The mirror system uses the connecting IP address of the client and the
#update status of each mirror to pick mirrors that are updated to and
#geographically close to the client. You should use this for CentOS updates
#unless you are manually picking other mirrors.

[base]
name=CentOS-$releasever - Base
baseurl=http://172.18.240.18:81/centos7/
#baseurl=file:///media
enabled=1
gpgcheck=0

step 5 安装docker

[root@localhost]# yum install --downloadonly -y yum-utils device-mapper-persistent-data lvm2
[root@localhost]# yum install --downloadonly -y docker-ce-17.12.1.ce && systemctl start docker

step 6 验证docker

[root@localhost]# docker --version

你可能感兴趣的:(linux)