如何在Dockerfile中定义Docker提交消息 [英] How to define docker commit message in Dockerfile

查看:53
本文介绍了如何在Dockerfile中定义Docker提交消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Dockerfile ( docker build )是手动执行 docker commit 的一种替代方法.通过使用 docker commit ,有一个名为-message 的选项,可用于定义提交消息.提交消息显示在 docker history 的专用列中,该列称为 COMMENT .我的问题是:如何在 Dockerfile 中定义docker commit消息?

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 :

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提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆