云游屋
扫描关注云游屋

云游屋

docker commit 命令

云游屋2021-09-06Docker命令 807

该命令的主要功能是把当前容器提交打包为镜像。

语法

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

常用参数

  • -a:添加作者信息,方便维护

  • -c:修改 Dockerfile 指令,目前支持以下指令:CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | ONBUILD | USER | VOLUME | WORKDIR

  • -m:提交修改信息

  • -p:在提交过程中暂停容器

实例

将名称为 helloworld 的容器打包为镜像,新镜像名称为 hello,标签为 new:

docker commit helloworld hello:new

注意

可以使用docker commit构建镜像,但是推荐使用 Dockerfile 构建镜像。

帮助

$ 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
  -m, --message string   Commit message
  -p, --pause            Pause container during commit (default true)


发表评论