322ggg 发表于 2018-1-22 10:24:16

在Centos7 系统中使用supermin制作CentOS6 的Docker镜像


使用supermin制作CentOS的Docker镜像
需求

supermin 在Centos7 里面安装默认只能够构建Centos7 版本的基础镜像,如果想进行构建Centos6基础镜像需要对Linux系统进行稍微做一下修改,主要体现在yum的源方面。
CentOS7上安装supermin5

# yum install supermin5 supermin5-devel -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* elrepo: hkg.mirror.rackspace.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 supermin5.x86_64.0.5.1.16-4.el7 将被 安装
---> 软件包 supermin5-devel.x86_64.0.5.1.16-4.el7 将被 安装
--> 正在处理依赖关系 rpm-build,它被软件包 supermin5-devel-5.1.16-4.el7.x86_64 需要
--> 正在检查事务
---> 软件包 rpm-build.x86_64.0.4.11.3-25.el7 将被 安装
--> 正在处理依赖关系 patch >= 2.5,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 elfutils >= 0.128,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 unzip,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 system-rpm-config,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 perl(Thread::Queue),它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 bzip2,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在处理依赖关系 /usr/bin/gdb-add-index,它被软件包 rpm-build-4.11.3-25.el7.x86_64 需要
--> 正在检查事务
---> 软件包 bzip2.x86_64.0.1.0.6-13.el7 将被 安装
---> 软件包 elfutils.x86_64.0.0.168-8.el7 将被 安装
---> 软件包 gdb.x86_64.0.7.6.1-100.el7 将被 安装
---> 软件包 patch.x86_64.0.2.7.1-8.el7 将被 安装
---> 软件包 perl-Thread-Queue.noarch.0.3.02-2.el7 将被 安装
---> 软件包 redhat-rpm-config.noarch.0.9.1.0-76.el7.centos 将被 安装
--> 正在处理依赖关系 dwz >= 0.4,它被软件包 redhat-rpm-config-9.1.0-76.el7.centos.noarch 需要
--> 正在处理依赖关系 zip,它被软件包 redhat-rpm-config-9.1.0-76.el7.centos.noarch 需要
--> 正在处理依赖关系 perl-srpm-macros,它被软件包 redhat-rpm-config-9.1.0-76.el7.centos.noarch 需要
---> 软件包 unzip.x86_64.0.6.0-16.el7 将被 安装
--> 正在检查事务
---> 软件包 dwz.x86_64.0.0.11-3.el7 将被 安装
---> 软件包 perl-srpm-macros.noarch.0.1-8.el7 将被 安装
---> 软件包 zip.x86_64.0.3.0-11.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=========================================================================================================================================================================
Package                                       架构                               版本                                          源                              大小
=========================================================================================================================================================================
正在安装:
supermin5                                     x86_64                           5.1.16-4.el7                                    base                           550 k
supermin5-devel                               x86_64                           5.1.16-4.el7                                    base                              14 k
为依赖而安装:
bzip2                                       x86_64                           1.0.6-13.el7                                    base                              52 k
dwz                                           x86_64                           0.11-3.el7                                    base                              99 k
elfutils                                    x86_64                           0.168-8.el7                                     base                           279 k
gdb                                           x86_64                           7.6.1-100.el7                                 base                           2.4 M
patch                                       x86_64                           2.7.1-8.el7                                     base                           110 k
perl-Thread-Queue                           noarch                           3.02-2.el7                                    base                              17 k
perl-srpm-macros                              noarch                           1-8.el7                                       base                           4.6 k
redhat-rpm-config                           noarch                           9.1.0-76.el7.centos                           base                              79 k
rpm-build                                     x86_64                           4.11.3-25.el7                                 base                           146 k
unzip                                       x86_64                           6.0-16.el7                                    base                           169 k
zip                                           x86_64                           3.0-11.el7                                    base                           260 k

事务概要
=========================================================================================================================================================================
安装2 软件包 (+11 依赖软件包)

总下载量:4.2 M
安装大小:11 M
Downloading packages:
(1/13): dwz-0.11-3.el7.x86_64.rpm                                                                                                               |99 kB00:00:00   
(2/13): perl-Thread-Queue-3.02-2.el7.noarch.rpm                                                                                                   |17 kB00:00:00   
(3/13): perl-srpm-macros-1-8.el7.noarch.rpm                                                                                                       | 4.6 kB00:00:00   
(4/13): patch-2.7.1-8.el7.x86_64.rpm                                                                                                            | 110 kB00:00:00   
(5/13): elfutils-0.168-8.el7.x86_64.rpm                                                                                                         | 279 kB00:00:00   
(6/13): rpm-build-4.11.3-25.el7.x86_64.rpm                                                                                                      | 146 kB00:00:00   
(7/13): redhat-rpm-config-9.1.0-76.el7.centos.noarch.rpm                                                                                          |79 kB00:00:00   
(8/13): supermin5-devel-5.1.16-4.el7.x86_64.rpm                                                                                                   |14 kB00:00:00   
(9/13): unzip-6.0-16.el7.x86_64.rpm                                                                                                               | 169 kB00:00:01   
(10/13): zip-3.0-11.el7.x86_64.rpm                                                                                                                | 260 kB00:00:01   
(11/13): supermin5-5.1.16-4.el7.x86_64.rpm                                                                                                      | 550 kB00:00:01   
(12/13): gdb-7.6.1-100.el7.x86_64.rpm                                                                                                             | 2.4 MB00:00:24   
bzip2-1.0.6-13.el7.x86_64.rpmFAILED                                          
http://mirrors.cqu.edu.cn/CentOS/7.4.1708/os/x86_64/Packages/bzip2-1.0.6-13.el7.x86_64.rpm: Timeout on http://mirrors.cqu.edu.cn/CentOS/7.4.1708/os/x86_64/Packages/bzip2-1.0.6-13.el7.x86_64.rpm: (28, 'Connection timed out after 30001 milliseconds')
正在尝试其它镜像。
(13/13): bzip2-1.0.6-13.el7.x86_64.rpm                                                                                                            |52 kB00:00:00   
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                     141 kB/s | 4.2 MB00:00:30   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装    : unzip-6.0-16.el7.x86_64                                                                                                                           1/13
正在安装    : patch-2.7.1-8.el7.x86_64                                                                                                                            2/13
正在安装    : supermin5-5.1.16-4.el7.x86_64                                                                                                                     3/13
正在安装    : elfutils-0.168-8.el7.x86_64                                                                                                                         4/13
正在安装    : dwz-0.11-3.el7.x86_64                                                                                                                               5/13
正在安装    : gdb-7.6.1-100.el7.x86_64                                                                                                                            6/13
正在安装    : zip-3.0-11.el7.x86_64                                                                                                                               7/13
正在安装    : bzip2-1.0.6-13.el7.x86_64                                                                                                                           8/13
正在安装    : perl-srpm-macros-1-8.el7.noarch                                                                                                                     9/13
正在安装    : redhat-rpm-config-9.1.0-76.el7.centos.noarch                                                                                                       10/13
正在安装    : perl-Thread-Queue-3.02-2.el7.noarch                                                                                                                11/13
正在安装    : rpm-build-4.11.3-25.el7.x86_64                                                                                                                     12/13
正在安装    : supermin5-devel-5.1.16-4.el7.x86_64                                                                                                                13/13
验证中      : supermin5-devel-5.1.16-4.el7.x86_64                                                                                                               1/13
验证中      : perl-Thread-Queue-3.02-2.el7.noarch                                                                                                               2/13
验证中      : perl-srpm-macros-1-8.el7.noarch                                                                                                                     3/13
验证中      : bzip2-1.0.6-13.el7.x86_64                                                                                                                           4/13
验证中      : zip-3.0-11.el7.x86_64                                                                                                                               5/13
验证中      : redhat-rpm-config-9.1.0-76.el7.centos.noarch                                                                                                      6/13
验证中      : gdb-7.6.1-100.el7.x86_64                                                                                                                            7/13
验证中      : rpm-build-4.11.3-25.el7.x86_64                                                                                                                      8/13
验证中      : dwz-0.11-3.el7.x86_64                                                                                                                               9/13
验证中      : elfutils-0.168-8.el7.x86_64                                                                                                                        10/13
验证中      : supermin5-5.1.16-4.el7.x86_64                                                                                                                      11/13
验证中      : patch-2.7.1-8.el7.x86_64                                                                                                                           12/13
验证中      : unzip-6.0-16.el7.x86_64                                                                                                                            13/13

已安装:
supermin5.x86_64 0:5.1.16-4.el7                                                supermin5-devel.x86_64 0:5.1.16-4.el7                                                

作为依赖被安装:
bzip2.x86_64 0:1.0.6-13.el7          dwz.x86_64 0:0.11-3.el7                   elfutils.x86_64 0:0.168-8.el7         gdb.x86_64 0:7.6.1-100.el7                        
patch.x86_64 0:2.7.1-8.el7         perl-Thread-Queue.noarch 0:3.02-2.el7   perl-srpm-macros.noarch 0:1-8.el7   redhat-rpm-config.noarch 0:9.1.0-76.el7.centos   
rpm-build.x86_64 0:4.11.3-25.el7   unzip.x86_64 0:6.0-16.el7               zip.x86_64 0:3.0-11.el7            

完毕!

修改centos 定制源

拷贝一份yum配置文件

cp /etc/yum.conf /home/yum.conf
修改一下 releasever 改为 6
sed -e -i 's/$releasever/6/g' /home/yum.conf

备份yum.repo.d 源

cp /etc/yum.repo.d /etc/yum.repo.d_bak
sed -e -i 's/^mirrorlist/#mirrorlist/g ;s/#baseurl/baseurl/g;s/$releasever/6/g;s/mirror.centos.org/mirrors.ustc.edu.cn/g' /etc/yum.repo.d/CentOS-Base.repo

创建镜像 (以下命令需要使用root运行)

# mkdir /home/centos6 -p
# cd /home/centos6
# supermin5 -v --prepare bash coreutils -o supermin.d --packager-config /home/yum.conf
可以安装一些 yum、vim 等, supermin5 -v --prepare bash coreutils -o supermin.d --packager-config /home/yum.conf
# supermin5 -v --build --format chroot supermin.d -o appliance.d
# echo 6 > appliance.d/etc/yum/vars/releasever

# tar --numeric-owner -cpf centos-6.tar -C appliance.d .
# cat centos-6.tar | docker import - registry.mychebao.com:5000/centos-6

查看镜像

docker images
REPOSITORY                            TAG               IMAGE ID            CREATED             SIZE
registry.mychebao.com:5000/centos-6   latest            766e94ff309a      About an hour ago   235MB

上传镜像到私有仓库

docker push registry.mychebao.com:5000/centos-6
The push refers to repository
0cb07a03e3df: Pushed
latest: digest: sha256:4f6f28a7d6aeefac72dd9457fd5d71ebf2d078958b2c08741d8f4796d78c5cf7 size: 528



页: [1]
查看完整版本: 在Centos7 系统中使用supermin制作CentOS6 的Docker镜像