前置条件:更换centos源为阿里云,详情见在https://itqh.com.cn/archives/1497bef2-fd38-442c-aba0-241a6bda5320
1.日期ntpdate设置
yum -y isntall ntpdate yum-utils
ntpdate ntp1.aliyun.com
2.创建docker 的yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
创建离线包存储目录,闭关设置读写权限
mkdir -p /opt/docker
chmod -R 777 /opt/docker
下载离线包到/opt/docker目录
yum install --downloadonly --downloaddir=/opt/docker yum-utils device-mapper-persistent-data lvm2 createrepo
安装createrepo和docker-ce依赖包
yum install -y device-mapper-persistent-data lvm2 createrepo
6.更新yum源索引,下载离线docker-ce包,版本号18.03.0
yum makecache fast
yum install --downloadonly --downloaddir=/opt/docker/ docker-ce-18.03.0.ce
7.下载密钥文件
cd /opt/docker
#前置条件 安装wget yum -y install wget
wget https://download.docker.com/linux/centos/gpg
8.初始化安装repodate源
cd /opt/docker
createrepo -pdo /opt/docker /opt/docker
createrepo --update /opt/docker
9.查看并制作安装包
cd /opt/docker
ll
tar -zcvf docker-local.tar.gz *
10.将centos的ISO镜像文件和docker-local.tar.gz文件上传到离线主机,并将centos的iso镜像文件挂在到/opt/centos目录,将cdocker-local.tar.gz文件解压到/opt/docker目录
mkdir -p /opt/docker /opt/centos
ls -R /opt
11.盖在iso系统镜像
mount -o loop /opt/centos/CentOS-7-x86_64-DVD-2009.iso /opt/centos
解压docker镜像
cd /opt/docker
tar -zxvf docker-local.tar.gz -C /opt/docker
13.配置docker-ce的yum源
rm -ivf /etc/yum.repos.d/*.repo //删除原有的repo文件
vi /etc/yum.repos.d/docker-ce.repo
添加以下内容
[docker]
name=docker ce
baseurl=file:///opt/docker
gpgcheck=0
enabled=1
gpgkey=file:///opt/docker/gpg
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
保存并退出
yum clean all
14.安装createrepo
yum -y install deltarpm libxml2-python python-deltarpm createrepo
createrepo -d /opt/docker/repodata
yum clean all
yum makecache fast
15.安装docker-ce,并检查docker-ce是否安装成功
yum -y install docker-ce
systemctl start docker
systemctl enable docker
docker version
评论区