/*運行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兩個功能 ,可以連接網絡 */