本文共 2059 字,大约阅读时间需要 6 分钟。
我们先来看一下我的机子上有那些容器
[qidai@qidai-pc ~]$ docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESb5c597a4f124 nginx "nginx -g 'daemon of…" 26 hours ago Exited (0) 23 hours ago webnginx76110444b847 91dadee7afee "docker-entrypoint.s…" 3 days ago Exited (0) 2 days ago my-test-mysql
我们更改后webnginx后现在进行保存
[qidai@qidai-pc ~]$ docker commit --author "qidai" --message "change webnginx index.html" webnginx nginx:v1sha256:ca9ac899159eefe41cf30771cc2f4e23db967d6e2f3d0725226495296b69cb76
--author
:指定作者--message
:备注信息保存后我们在来看一下本地image
[qidai@qidai-pc ~]$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx v1 ca9ac899159e 3 minutes ago 109MBnginx latest 881bd08c0b08 4 days ago 109MBubuntu latest 47b19964fb50 4 weeks ago 88.1MBcentos latest 1e1148e4cc2c 3 months ago 202MB
会多出来一个nginx:v1镜像,我们把它run起来
[qidai@qidai-pc ~]$ docker run --rm -d -p 80:80 nginx:v11c494ae39be7666f1c3249054b5657b24bebe192009761d1063e424f601bb672[qidai@qidai-pc ~]$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1c494ae39be7 nginx:v1 "nginx -g 'daemon of…" 9 seconds ago Up 7 seconds 0.0.0.0:80->80/tcp recursing_zhukovsky
虽然commit可以为我们定制镜像,但还是要 慎用 原因如下
转载地址:http://tcukx.baihongyu.com/