← 返回命令列表

Linux command

docker-commit 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create image from container

docker commit [container_id] [image_name:tag]

Commit with author info

docker commit --author "[name]" [container_id] [image:tag]

Commit with message

docker commit -m "[Added config files]" [container_id] [image:tag]

Commit with changed CMD

docker commit --change "CMD ['/app/start.sh']" [container_id] [image:tag]

说明

docker commit creates a new image from a container's changes. This captures the current state of a container's filesystem as a new image layer by examining all modifications made since the container was created. While useful for debugging, experimentation, or saving a working state, this approach is not recommended for production workflows. Dockerfiles provide better reproducibility, version control, and documentation of the build process. Committed images lack the transparent layer history that Dockerfiles provide, making them harder to maintain and audit.

参数

-a, --author _string_
Author of the image.
-c, --change _list_
Apply Dockerfile instructions to the image.
-m, --message _string_
Commit message.
-p, --pause
Pause container during commit (default true).

FAQ

What is the docker-commit command used for?

docker commit creates a new image from a container's changes. This captures the current state of a container's filesystem as a new image layer by examining all modifications made since the container was created. While useful for debugging, experimentation, or saving a working state, this approach is not recommended for production workflows. Dockerfiles provide better reproducibility, version control, and documentation of the build process. Committed images lack the transparent layer history that Dockerfiles provide, making them harder to maintain and audit.

How do I run a basic docker-commit example?

Run `docker commit [container_id] [image_name:tag]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --author _string_ do in docker-commit?

Author of the image.