码迷,mamicode.com
首页 > 其他好文 > 详细

创建镜像

时间:2019-12-10 13:15:27      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:server   com   x86   图片   安装   cal   inux   install   bash   

 

 

            技术图片

[root@localhost ~]# docker images
REPOSITORY        TAG             IMAGE ID                CREATED                SIZE
nginx                       1                  231d40e811cd         2 weeks ago           126MB
nginx                      latest             231d40e811cd        2 weeks ago            126MB

centos                    1                   70d2e28b0f3b         6 seconds ago         589MB

[root@localhost ~]# docker run -it --name web centos:1 /bin/bash                 #在容器内安装httpd服务
root@152737da7cca:/# yum install httpd -y

[root@localhost ~]# docker ps -a
CONTAINER ID         IMAGE                COMMAND          CREATED           STATUS              PORTS           NAMES
9fb690ed82a5           centos:1             "/bin/bash"              2 minutes ago        Up 2 minutes

将这个centos镜像进行打包

[root@localhost ~]# docker commit -m "httpd server" -a "crushlinux" 9fb690ed82a5 httpd:2.2.18
sha256:e3675919d5b2d4392ce2ade734ab1c54f3a7101cfe137836918573dc14c117e6
[root@localhost ~]# docker images
REPOSITORY              TAG               IMAGE ID                  CREATED                   SIZE
httpd                             2.2.18           e3675919d5b2           5 seconds ago                590MB               
centos                         1                    70d2e28b0f3b             10 minutes ago              589MB
nginx                           1                    231d40e811cd            2 weeks ago                   126MB
nginx                          latest              231d40e811cd             2 weeks ago                   126MB

[root@localhost ~]# docker run -it httpd:2.2.18 /bin/bash
[root@0f2a418b5c3d /]# rpm -q httpd
httpd-2.4.6-40.el7.centos.1.x86_64                                #这个是刚才下载好的httpd服务

 

 

技术图片

 

 这里面都是纯净版的centos镜像,下载完成后利用下面这条命令进行导入到docker images中

[root@localhost a]# cat 镜像包 | docker import - 镜像名:标签名

 

 

 

创建镜像

标签:server   com   x86   图片   安装   cal   inux   install   bash   

原文地址:https://www.cnblogs.com/CMX_Shmily/p/12015900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!