前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在Centos7 系统中使用supermin制作CentOS6 的Docker镜像

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

作者头像
拓荒者
发布2019-03-11 11:14:44
1.4K0
发布2019-03-11 11:14:44
举报
文章被收录于专栏:运维经验分享运维经验分享

使用supermin制作CentOS的Docker镜像

需求

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

CentOS7上安装supermin5

代码语言:javascript
复制
# 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 kB  00:00:00     
(2/13): perl-Thread-Queue-3.02-2.el7.noarch.rpm                                                                                                   |  17 kB  00:00:00     
(3/13): perl-srpm-macros-1-8.el7.noarch.rpm                                                                                                       | 4.6 kB  00:00:00     
(4/13): patch-2.7.1-8.el7.x86_64.rpm                                                                                                              | 110 kB  00:00:00     
(5/13): elfutils-0.168-8.el7.x86_64.rpm                                                                                                           | 279 kB  00:00:00     
(6/13): rpm-build-4.11.3-25.el7.x86_64.rpm                                                                                                        | 146 kB  00:00:00     
(7/13): redhat-rpm-config-9.1.0-76.el7.centos.noarch.rpm                                                                                          |  79 kB  00:00:00     
(8/13): supermin5-devel-5.1.16-4.el7.x86_64.rpm                                                                                                   |  14 kB  00:00:00     
(9/13): unzip-6.0-16.el7.x86_64.rpm                                                                                                               | 169 kB  00:00:01     
(10/13): zip-3.0-11.el7.x86_64.rpm                                                                                                                | 260 kB  00:00:01     
(11/13): supermin5-5.1.16-4.el7.x86_64.rpm                                                                                                        | 550 kB  00:00:01     
(12/13): gdb-7.6.1-100.el7.x86_64.rpm                                                                                                             | 2.4 MB  00:00:24     
bzip2-1.0.6-13.el7.x86_64.rpm  FAILED                                          
http://mirrors.cqu.edu.cn/CentOS/7.4.1708/os/x86_64/Packages/bzip2-1.0.6-13.el7.x86_64.rpm: [Errno 12] 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 kB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                     141 kB/s | 4.2 MB  00: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配置文件

代码语言:javascript
复制
 cp /etc/yum.conf /home/yum.conf
 修改一下 releasever 改为 6
 sed -e -i 's/$releasever/6/g' /home/yum.conf

备份yum.repo.d 源

代码语言:javascript
复制
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运行)

代码语言:javascript
复制
# 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

查看镜像

代码语言:javascript
复制
docker images
REPOSITORY                            TAG                 IMAGE ID            CREATED             SIZE
registry.mychebao.com:5000/centos-6   latest              766e94ff309a        About an hour ago   235MB

上传镜像到私有仓库

代码语言:javascript
复制
docker push registry.mychebao.com:5000/centos-6
The push refers to repository [registry.mychebao.com:5000/centos-6]
0cb07a03e3df: Pushed 
latest: digest: sha256:4f6f28a7d6aeefac72dd9457fd5d71ebf2d078958b2c08741d8f4796d78c5cf7 size: 528

©著作权归作者所有:来自51CTO博客作者jin771998569的原创作品,如需转载,请与作者联系,否则将追究法律责任

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/08/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 使用supermin制作CentOS的Docker镜像
    • 需求
      • CentOS7上安装supermin5
        • 修改centos 定制源
          • 创建镜像 (以下命令需要使用root运行)
            • 查看镜像
              • 上传镜像到私有仓库
              相关产品与服务
              容器服务
              腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档