docker使用现有容器生成新的镜像

/*运行docker run后 --则进入该容器里了 

            我们做一些变更,比如安装一些东西 ,然后针对这个容器进行创建新的镜像
*/

基本形式:

docker commit -m "change somth" -a "somebody info" container_id(docker ps -a获取id) 新镜像名字

eg.
Ian 
docker commit -m "install httpd" -a   ”frank  ie" 2c74d574293f frankie/centos  
  
/* 意义就是 为某一个功能,创建一个镜像    */

docker exec -it de8[id的简写] /bin/bash    --进入容器
/*
实例:
进入容器后,ifconfig ,wget等命令都不存在 可以利用yum进行安装 */ [root@64b1a3401832 /]# yum install -y net-tools wget //查看此容器的版本 [root@64b1a3401832 /]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@64b1a3401832 /]# uname -a Linux 64b1a3401832 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux //然后对刚刚的容器进行新创建,要回到原来的shell里 [root@localhost ~]# docker commit -m "centos_with_nettools_and_wget" -a "Frankie(作者名)" 64b centos_with_net c5b412fe1c33f5dd98030c5ed22503b255eca0aac21175e7312465db4cb595cf [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos_with_net latest c5b412fe1c33 27 seconds ago 294.1 MB centos latest d83a55af4e75 4 weeks ago 196.7 MB frankie latest d83a55af4e75 4 weeks ago 196.7 MB [root@localhost ~]# /* 此时创建的镜像里 , 有ifconfig 和 wget两个功能 ,可以连接网络 */

 

转载于:https://www.cnblogs.com/frankielf0921/p/5817928.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值