一种docker基础镜像制作方法

kevin.Zhu 发布于:2014-1-22 13:06 分类:Linux  有 24 人浏览,获得评论 0 条  

这种制作方法很简单,三步

1. 用安装盘安装一个操作系统,这里用的是CentOS-6.7-x86_64-minimal.iso在虚拟机下安装。

2.用tar命令将安装好后的操作系统转换成一个tar文件。

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos6-base.tar /  

3.在一台可运行Docker的机器上用docker import命令转换成docker image

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. cat centos6-base.tar | docker import - centos6-base  

运行验证
[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. [root@cloud-1 ~]# docker images  
  2. REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE  
  3. centos6-base        latest              c4c7d099ff2f        3 hours ago         544.6 MB  
  4. [root@cloud-1 ~]#    
  5. [root@cloud-1 ~]# docker run -i -t centos6-base cat /etc/redhat-release  
  6. Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.  
  7. CentOS release 6.7 (Final)  
  8. [root@cloud-1 ~]#