如何在 Dockerfile 中定义 docker commit 消息 [英] How to define docker commit message in Dockerfile
问题描述
使用 Dockerfile
(docker build
) 是手动执行 docker commit
的替代方法.通过使用 docker commit
,有一个名为 --message
的选项,可用于定义提交消息.提交消息显示在 docker history
中名为 COMMENT
的专用列中.我的问题是:如何在 Dockerfile
中定义 docker 提交消息?
Using Dockerfile
(docker build
) is an alternative for doing docker commit
by hand. By using docker commit
, there is an option named --message
, which can be used to define commit messages. Commit messages are displayed in docker history
in a dedicated column called COMMENT
. My question is: how to define docker commit message in a Dockerfile
?
推荐答案
使用 Dockerfile
和 docker build
你可以创建一个全新的镜像.因此,您没有任何可以用消息评论的更改.无法在 Dockerfile
中定义提交消息.
With a Dockerfile
and docker build
you create a completely new image. Therefore you do not have any changes that can be commented with a message. It is not possible to define a commit message in a Dockerfile
.
正如文档指出的那样,docker commit
对于调试目的更有用.要创建新映像,建议使用 docker build
:https://docs.docker.com/engine/reference/commandline/commit/#extended-description
As the docs point out docker commit
is more useful for debugging purposes. To create a new image, docker build
is recommended: https://docs.docker.com/engine/reference/commandline/commit/#extended-description
这是有道理的,因为提交的图像很难重现,只有提交消息作为更改的提示.只使用 Dockerfile 总是会产生可重现的构建.
This makes sense, as committed images are hard to reproduce, with only a commit message as a hint on the changes. Using only a Dockerfile always leads to a reproducable build.
这篇关于如何在 Dockerfile 中定义 docker commit 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!