Docker 镜像创建

在 docker 中, 创建镜像的方式有3种方式:

  1. 基于现有容器创建镜像
  2. 基于 Dockerfile 创建镜像
  3. 通过本地模版文件创建镜像

基于现有容器创建镜像

关键点是docker commit命令.
通常,当我们对一个现有容器进行修改后,我们使用docker commit命令可以提交该容器,从而生成一个新的镜像.
我们来看下docker commit命令帮助:

~ # 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
      --help             Print usage
  -m, --message string   Commit message
  -p, --pause            Pause container during commit (default true)

基于 Dockerfile 创建镜像

通过本地模版文件创建镜像

原文地址:https://www.cnblogs.com/taadis/p/12126125.html