目录
[1 查看系统内核](#1 查看系统内核)
[2 获取网络源](#2 获取网络源)
[3 搭建yum网络仓库](#3 搭建yum网络仓库)
[4 rpm包的下载](#4 rpm包的下载)
[4.1 将rpm包下载至本地](#4.1 将rpm包下载至本地)
[4.2 对下载的rpm包进行备份](#4.2 对下载的rpm包进行备份)
[5 制作本地yum源](#5 制作本地yum源)
[5.1 软件仓库制作工具createrepo](#5.1 软件仓库制作工具createrepo)
[5.2 使用createrepo创建本地yum仓库](#5.2 使用createrepo创建本地yum仓库)
[6 搭建docker本地仓库](#6 搭建docker本地仓库)
前言:
此次实验使用的系统为 openEuler 22.03,制作docker-ce的yum仓库。
问题来了yum仓库的制作首先前提是得有rpm软件包为基础。
这个时候得去哪里获取呢?
1 查看系统内核
这里能很清楚地看出来openEuler22.03他的Linux内核使用的为 Linux-5.10.0
同样RHEL 9 使用的内核也是 Linux-5,所以软件是互为通用的
bash
[root@localhost yum.repos.d]# hostnamectl
Static hostname: n/a
Transient hostname: localhost
Icon name: computer-vm
Chassis: vm
Machine ID: 052542e981c9468b9a0cc82cb54dccc9
Boot ID: 874f2ac2da7a4c089bbc5ee2108e4816
Virtualization: vmware
Operating System: openEuler 22.03 (LTS-SP4)
Kernel: Linux 5.10.0-216.0.0.115.oe2203sp4.x86_64
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
2 获取网络源
阿里云镜像站https://developer.aliyun.com/mirror/
此次使用的为阿里云的镜像源,搭建docker-ce软件的网络源,使用网络源将rpm包下载到本地并制作本地yum仓库
3 搭建yum网络仓库
bash
[root@localhost yum.repos.d]# vim docker-ce.repo
[docker]
name=docker-ce
baseurl=https://mirrors.aliyun.com/docker-ce/linux/rhel/9/x86_64/stable/
gpgcheck=0
4 rpm包的下载
4.1 将rpm包下载至本地
yum 有一个选项是能将rpm包下载到当前目录:
--downloaddir 与 --downloadonly 配合使用
bash
[root@localhost ~]# yum install docker-ce --downloaddir=/usr/local/src/docker --downloadonly
Last metadata expiration check: 0:26:30 ago on 2024年08月02日 星期五 15时42分17秒.
Dependencies resolved.
============================================================================================
Package Architecture Version Repository Size
============================================================================================
Installing:
docker-ce x86_64 3:27.1.1-1.el9 docker 27 M
Installing dependencies:
container-selinux noarch 2:2.138-5.oe2203sp4 OS 33 k
containerd.io x86_64 1.7.19-3.1.el9 docker 43 M
docker-ce-cli x86_64 1:27.1.1-1.el9 docker 7.8 M
fuse-overlayfs x86_64 1.12-1.oe2203sp4 EPOL 54 k
fuse3 x86_64 3.10.5-9.oe2203sp4 OS 111 k
libslirp x86_64 4.7.0-2.oe2203sp4 OS 66 k
slirp4netns x86_64 1.2.0-1.oe2203sp4 EPOL 43 k
Installing weak dependencies:
docker-buildx-plugin x86_64 0.16.1-1.el9 docker 14 M
docker-ce-rootless-extras x86_64 27.1.1-1.el9 docker 4.0 M
docker-compose-plugin x86_64 2.29.1-1.el9 docker 13 M
fuse3-help x86_64 3.10.5-9.oe2203sp4 OS 8.9 k
Transaction Summary
============================================================================================
Install 12 Packages
Total download size: 109 M
Installed size: 423 M
YUM will only download packages for the transaction.
Is this ok [y/N]: y
Downloading Packages:
(1/12): docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm 489 kB/s | 14 MB 00:28
(2/12): docker-ce-cli-27.1.1-1.el9.x86_64.rpm 481 kB/s | 7.8 MB 00:16
(3/12): docker-ce-27.1.1-1.el9.x86_64.rpm 518 kB/s | 27 MB 00:52
(4/12): docker-ce-rootless-extras-27.1.1-1.el9.x86_64.rpm 453 kB/s | 4.0 MB 00:09
(5/12): container-selinux-2.138-5.oe2203sp4.noarch.rpm 104 kB/s | 33 kB 00:00
(6/12): fuse3-3.10.5-9.oe2203sp4.x86_64.rpm 1.3 MB/s | 111 kB 00:00
(7/12): fuse3-help-3.10.5-9.oe2203sp4.x86_64.rpm 217 kB/s | 8.9 kB 00:00
(8/12): libslirp-4.7.0-2.oe2203sp4.x86_64.rpm 1.3 MB/s | 66 kB 00:00
(9/12): fuse-overlayfs-1.12-1.oe2203sp4.x86_64.rpm 193 kB/s | 54 kB 00:00
(10/12): slirp4netns-1.2.0-1.oe2203sp4.x86_64.rpm 731 kB/s | 43 kB 00:00
(11/12): docker-compose-plugin-2.29.1-1.el9.x86_64.rpm 489 kB/s | 13 MB 00:28
(12/12): containerd.io-1.7.19-3.1.el9.x86_64.rpm 485 kB/s | 43 MB 01:31
--------------------------------------------------------------------------------------------
Total 1.2 MB/s | 109 MB 01:32
retrieving repo key for OS unencrypted from http://repo.openeuler.org/openEuler-22.03-LTS-SP4/OS/x86_64/RPM-GPG-KEY-openEuler
OS 15 kB/s | 3.0 kB 00:00
Importing GPG key 0xB675600B:
Userid : "openeuler <openeuler@compass-ci.com>"
Fingerprint: 8AA1 6BF9 F2CA 5244 010D CA96 3B47 7C60 B675 600B
From : http://repo.openeuler.org/openEuler-22.03-LTS-SP4/OS/x86_64/RPM-GPG-KEY-openEuler
Is this ok [y/N]: y
Key imported successfully
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
查看是否下载成功
4.2 对下载的rpm包进行备份
制作仓库之前首先需要对rpm包进行备份
bash
[root@localhost docker]# cp /usr/local/src/docker/* /usr/local/src/docker-bak/
[root@localhost docker]# ls ../docker-bak/
containerd.io-1.7.19-3.1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm
docker-ce-cli-27.1.1-1.el9.x86_64.rpm
docker-ce-rootless-extras-27.1.1-1.el9.x86_64.rpm
docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
fuse3-3.10.5-9.oe2203sp4.x86_64.rpm
fuse3-help-3.10.5-9.oe2203sp4.x86_64.rpm
fuse-overlayfs-1.12-1.oe2203sp4.x86_64.rpm
libslirp-4.7.0-2.oe2203sp4.x86_64.rpm
slirp4netns-1.2.0-1.oe2203sp4.x86_64.rpm
5 制作本地yum源
5.1 软件仓库制作工具createrepo
bash
[root@localhost docker]# yum install createrepo
Last metadata expiration check: 0:36:15 ago on 2024年08月02日 星期五 15时42分17秒.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
createrepo_c x86_64 0.17.6-3.oe2203sp4 OS 133 k
Installing dependencies:
drpm x86_64 0.5.1-1.oe2203sp4 OS 56 k
Transaction Summary
=====================================================================================================================================================
Install 2 Packages
5.2 使用createrepo创建本地yum仓库
bash
[root@localhost src]# ls docker
containerd.io-1.7.19-3.1.el9.x86_64.rpm docker-ce-cli-27.1.1-1.el9.x86_64.rpm fuse3-help-3.10.5-9.oe2203sp4.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-ce-rootless-extras-27.1.1-1.el9.x86_64.rpm fuse-overlayfs-1.12-1.oe2203sp4.x86_64.rpm
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm docker-compose-plugin-2.29.1-1.el9.x86_64.rpm libslirp-4.7.0-2.oe2203sp4.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm fuse3-3.10.5-9.oe2203sp4.x86_64.rpm slirp4netns-1.2.0-1.oe2203sp4.x86_64.rpm
[root@localhost src]# createrepo -v /usr/local/src/docker
16:23:53: Version: 0.17.6 (Features: DeltaRPM LegacyWeakdeps )
16:23:53: Signal handler setup
16:23:53: Thread pool ready
Directory walk started
16:23:53: Adding pkg: /usr/local/src/docker/docker-ce-cli-27.1.1-1.el9.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/container-selinux-2.138-5.oe2203sp4.noarch.rpm
16:23:53: Adding pkg: /usr/local/src/docker/docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/slirp4netns-1.2.0-1.oe2203sp4.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/containerd.io-1.7.19-3.1.el9.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/libslirp-4.7.0-2.oe2203sp4.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/fuse3-3.10.5-9.oe2203sp4.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/fuse-overlayfs-1.12-1.oe2203sp4.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/docker-ce-27.1.1-1.el9.x86_64.rpm
16:23:53: Dir to scan: /usr/local/src/docker/.repodata
16:23:53: Adding pkg: /usr/local/src/docker/docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/docker-ce-rootless-extras-27.1.1-1.el9.x86_64.rpm
16:23:53: Adding pkg: /usr/local/src/docker/fuse3-help-3.10.5-9.oe2203sp4.x86_64.rpm
16:23:53: Package count: 12
Directory walk done - 12 packages
Temporary output repo path: /usr/local/src/docker/.repodata/
16:23:53: Creating .xml.gz files
16:23:53: Setting number of packages
Preparing sqlite DBs
16:23:53: Creating databases
16:23:53: Thread pool user data ready
Pool started (with 5 workers)
Pool finished
16:23:53: Generating repomd.xml
16:23:53: Old repodata doesn't exists: Cannot rename /usr/local/src/docker/repodata/ -> /usr/local/src/docker/repodata.old.2366.20240802162353.139730: No such file or directory
16:23:53: Renamed /usr/local/src/docker/.repodata/ -> /usr/local/src/docker/repodata/
16:23:53: Memory cleanup
16:23:53: All done
[root@localhost src]# ls docker
containerd.io-1.7.19-3.1.el9.x86_64.rpm docker-ce-rootless-extras-27.1.1-1.el9.x86_64.rpm libslirp-4.7.0-2.oe2203sp4.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm docker-compose-plugin-2.29.1-1.el9.x86_64.rpm repodata
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm fuse3-3.10.5-9.oe2203sp4.x86_64.rpm slirp4netns-1.2.0-1.oe2203sp4.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm fuse3-help-3.10.5-9.oe2203sp4.x86_64.rpm
docker-ce-cli-27.1.1-1.el9.x86_64.rpm fuse-overlayfs-1.12-1.oe2203sp4.x86_64.rpm
6 搭建docker本地仓库
将yum仓库源切换为本地制作的yum仓库
bash
[root@localhost ~]# vim /etc/yum.repos.d/docker-ce.repo
[docker]
name=docker-ce
# baseurl=https://mirrors.aliyun.com/docker-ce/linux/rhel/9/x86_64/stable/
baseurl=file:///usr/local/src/docker
gpgcheck=0
重新加载yum仓库
bash
[root@localhost ~]# yum makecache
使用自己制作的本地仓库下载docker-ce
成功启动并使用