欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos7离线docker18

程序员文章站 2022-05-27 16:39:44
...

有网centos7机器上制作本地源

1、创建rpm包的存放路径

mkdir -p /home/docker/local
chmod -R 777 /home/docker/local

2、下载制作本地源所需要的工具

yum install --downloadonly \
	--downloaddir=/home/docker/local \
	yum-utils device-mapper-persistent-data \
	lvm2 createrepo

3、安装createrepo以及其依赖包

yum install yum-utils \
	device-mapper-persistent-data \
	lvm2 createrepo

4、配置、更新yum源索引

yum-config-manager \
	--add-repo \
	https://download.docker.com/linux/centos/docker-ce.repo
yum makecache fast

5、下载docker-ce及其依赖包

yum install --downloadonly --downloaddir=/home/docker/local docker-ce

6、获取**文件

more /etc/yum.repos.d/docker-ce.repo


[docker-ce-stable]

name=Docker CE Stable - $basearch

baseurl=https://download.docker.com/linux/centos/7/$basearch/stable

enabled=1

gpgcheck=1

gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]

name=Docker CE Stable - Debuginfo $basearch

baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable

enabled=0

gpgcheck=1

gpgkey=https://download.docker.com/linux/centos/gpg

下载**文件

cd /home/docker/local
wget https://download.docker.com/linux/centos/gpg

7、初始化yum源

createrepo -pdo /home/docker/local /home/docker/local

createrepo --update /home/docker/local

此时,/home/docker/local下面应该有如下rpm安装包

8、打包导出docker源

cd /home/docker/local

tar -zcvf docker.tar.gz ./*

在无网机器上安装docker18

1、拷贝docker.tar.gz至无网的机器

2、安装docker18

tar xvzf docker.tar.gz

yum -y localinstall ./*.rpm

3、启动docker

systemctl start docker
systemctl enable docker

如果yum安装报错,尝试配置本地yum源