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