docker buildx imagetools 创建

DescriptionCreate a new image based on source images
Usagedocker buildx imagetools create [OPTIONS] [SOURCE] [SOURCE...]

描述

基于源清单创建一个新的清单列表。源清单可以是清单列表或单一平台分发清单,并且必须已经存在于创建新清单的注册表中。

如果只指定了一个源并且该源是一个清单列表或镜像索引,create 会执行一个完全复制。如果指定了一个源并且该源不是列表或索引,输出将是一个清单列表,但是你可以通过--prefer-index=false禁用此行为,该选项尝试在输出中保留源清单格式。

选项

OptionDefaultDescription
--annotationAdd annotation to the image
--appendAppend to existing manifest
--dry-runShow final image instead of pushing
-f, --fileRead source descriptor from file
--prefer-indextrueWhen only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy
--progressautoSet type of progress output (auto, plain, tty, rawjson). Use plain to show container output
-t, --tagSet reference for new image

示例

向图像添加注释 (--annotation)

--annotation 标志允许你在创建新镜像时为镜像索引、清单和描述符添加注释。

以下命令创建一个带有org.opencontainers.image.authors注释的foo/bar:latest镜像。

$ docker buildx imagetools create \
  --annotation "index:org.opencontainers.image.authors=dvdksn" \
  --tag foo/bar:latest \
  foo/bar:alpha foo/bar:beta foo/bar:gamma

注意

imagetools create 命令支持向图像索引和描述符添加注释,使用以下类型前缀:

  • index:
  • manifest-descriptor:

它不支持注释清单或OCI布局。

有关注释的更多信息,请参阅 注释

将新源附加到现有的清单列表 (--append)

使用--append标志将新源附加到目标中的现有清单列表中。

覆盖配置的构建器实例 (--builder)

buildx --builder相同。

显示最终图像而不是推送 (--dry-run)

使用--dry-run标志来不推送镜像,仅显示它。

从文件中读取源描述符 (-f, --file)

-f FILE or --file FILE

从文件中读取源。源可以是清单摘要、清单引用或OCI描述符对象的JSON。

为了定义注释或额外的平台属性,如os.versionos.features,您需要将它们添加到以JSON编码的OCI描述符对象中。

$ docker buildx imagetools inspect --raw alpine | jq '.manifests[0] | .platform."os.version"="10.1"' > descr.json
$ docker buildx imagetools create -f descr.json myuser/image

文件中的描述符将与注册表中现有的描述符合并(如果存在)。

描述符支持的字段在 OCI 规范 中定义。

为新图像设置引用 (-t, --tag)

-t IMAGE or --tag IMAGE

使用 -t--tag 标志来设置要创建的镜像的名称。

$ docker buildx imagetools create --dry-run alpine@sha256:5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 sha256:c4ba6347b0e4258ce6a6de2401619316f982b7bcc529f73d2a410d0097730204
$ docker buildx imagetools create -t tonistiigi/myapp -f image1 -f image2