docker commit

命令:docker commit

[root@iZ943kh74qgZ ~]# docker commit --help

Usage:    docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Create a new image from a container's changes

Options:
  -a, --author string    Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")作者与邮箱
  -c, --change list      Apply Dockerfile instruction to the created image使用dockerfile文件系统指令来创建镜像。
      --help             Print usage
  -m, --message string   Commit message提交的信息
  -p, --pause            Pause container during commit (default true)

当容器里的内容改变时,创建一个新的镜像。

但这个命令有个问题,虽然他是很容易修改镜像然后再制作。但如果多个文件被改动,或多次改动,这个镜像就会变得很臃肿的了。他相当于每次改了什么都会记录下来,一层层覆盖。那就是会有好多无用的信息存在。所以一般用于测试。

而实际生产过程中,我们可以使用镜像+脚本的形式来修改镜像,每当重启又再覆盖。这种脚本就是dockerfile

原文地址:https://www.cnblogs.com/gorgage/p/7285054.html