Обычно это сохраняется для управления базовыми инструментами. Это часть истории слоя spe c:
// History describes the history of a layer.
type History struct {
// Created is the combined date and time at which the layer was created, formatted as defined by RFC 3339, section 5.6.
Created *time.Time `json:"created,omitempty"`
// CreatedBy is the command which created the layer.
CreatedBy string `json:"created_by,omitempty"`
// Author is the author of the build point.
Author string `json:"author,omitempty"`
// Comment is a custom message set when creating the layer.
Comment string `json:"comment,omitempty"`
// EmptyLayer is used to mark if the history item created a filesystem diff.
EmptyLayer bool `json:"empty_layer,omitempty"`
}
Вы увидите историю этого слоя в docker image history
, а docker image inspect
, похоже, извлекает значение из последний слой.
Некоторые инструменты, такие как buildkit, получают жестко заданное значение :
if len(diffs) > historyLayers {
// some history items are missing. add them based on the ref metadata
for _, md := range refMeta[historyLayers:] {
history = append(history, ocispec.History{
Created: &md.createdAt,
CreatedBy: md.description,
Comment: "buildkit.exporter.image.v0",
})
}
}
С Dockerfile, созданным классом c docker build
, я не знаю ни одного способа установить это поле комментария для отдельных шагов.
Как упоминал Радже sh, вы можете установить комментарий с помощью команды docker commit
, которую я не знаю рекомендуется использовать для любых изображений, собираемых в производство, так как изображение необходимо создавать вручную, чтобы избежать ошибок.
Вместо этого типичный способ добавления метаданных к изображению docker - это установить метку в Dockefile .
LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
LABEL version="1.0"
LABEL description="This text illustrates \
that label-values can span multiple lines."
Эти метки также копируются в метаданные контейнера когда он порождается из этого изображения, и они унаследованы от родительского изображения (заданного в строке FROM
), поэтому обязательно замените метку в дочерних изображениях, чтобы избежать путаницы.