docker commit ${容器名} ${镜像名}
例如
查看目前的容器
docker container list
返回
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e7ec3c44514 eeb6ee3f44bd "/usr/sbin/init" 9 days ago Up 49 minutes 0.0.0.0:2229->22/tcp cdh03
f140e7fe634c eeb6ee3f44bd "/usr/sbin/init" 9 days ago Up 49 minutes 0.0.0.0:2228->22/tcp cdh02
a6d039150d75 eeb6ee3f44bd "/usr/sbin/init" 9 days ago Up 49 minutes 0.0.0.0:7180->7180/tcp, 0.0.0.0:7183->7183/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:9870->9870/tcp, 0.0.0.0:16010->16010/tcp, 0.0.0.0:18088->18088/tcp, 0.0.0.0:8000->8000/udp, 0.0.0.0:2227->22/tcp cdh01
能看到目前有三个容器
想将容器id为"a6d039150d75"导成镜像,可以看到容器名为"cdh01"
命令为
docker commit cdh01 image_cdh01
查看镜像
docker images
返回
REPOSITORY TAG IMAGE ID CREATED SIZE
image_cdh01 latest 78857c99e3da 47 minutes ago 11.6GB
centos <none> eeb6ee3f44bd 19 months ago 204MB
可以看到新的镜像已经生成
网友评论