docker commit
根据容器的更改创建新图像
将容器的文件更改或设置提交到新映像中可能很有用。这使您可以通过运行交互式外壳程序来调试容器,或将工作数据集导出到另一台服务器。通常,最好使用Dockerfiles以文档化和可维护的方式来管理映像。
- Docker 相关文章
- https://www.262235.xyz/index.php/tag/docker/
例子 commit
提交容器
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ba21356c8dea debian "bash" About a minute ago Exited (0) 15 seconds ago peaceful_sammet
$ docker commit ba21356c8dea myphp
sha256:b795a0199077c8b48ff48193dee3268b517df99cdd258dc49a6929694b6ce57b
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myphp latest b795a0199077 15 seconds ago 271MB
debian latest 82bd5ee7b1c5 3 weeks ago 124MB
查看镜像历史
$ docker history myphp
IMAGE CREATED CREATED BY SIZE COMMENT
b795a0199077 25 seconds ago bash 147MB
82bd5ee7b1c5 3 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:1fedf68870782f1b4… 124MB
使用myphp镜像建立容器
$ docker run -itd myphp bash
46b98f18d17249674b7cdebd1161a65285aaafb94f193cd7ab76294571334224
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
46b98f18d172 myphp "bash" 16 seconds ago Up 14 seconds zealous_mirzakhani
$ docker exec -it 46b98f18d172 php -v
PHP 7.4.21 (cli) (built: Jul 2 2021 03:59:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
$ docker exec -it 46b98f18d172 bash
依赖安装Debian/Ubuntuapt-get update apt-get install python wget screen -yCentOS/RHELyum install screen wget python -y使用方法screen -S upi…
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册