docker buildx imagetools 创建

描述基于源镜像创建新镜像
用法docker buildx imagetools create [OPTIONS] [SOURCE] [SOURCE...]

描述

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

如果只指定了一个源,并且该源是清单列表或镜像索引,则 create 执行 carbon copy。如果指定了一个源,并且该源不是列表或索引,则输出将是清单列表,但您可以禁用此功能 行为替换为--prefer-index=false尝试保留源清单 format 在输出中。

选项

选择违约描述
--annotation向镜像添加注释
--append附加到现有清单
--dry-run显示最终镜像而不是推送
-f, --file从文件中读取源描述符
--prefer-indextrue当仅指定单个源时,最好输出镜像索引或清单列表,而不是执行抄送
--progressauto设置进度输出的类型 (auto,plain,tty,rawjson).使用 plain 显示容器输出
-t, --tag为新镜像设置引用

例子

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

--annotationflag 允许您添加注释 image index、manifest、 和描述符。

以下命令创建一个foo/bar:latestimage 替换为org.opencontainers.image.authors注释。

$ 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 和 descriptor,使用以下类型前缀:

  • index:
  • manifest-descriptor:

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

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

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

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

覆盖配置的生成器实例 (--builder)

等同buildx --builder.

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

使用--dry-runflag 来不推送镜像,只显示它。

从文件中读取源描述符 (-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 spec 中定义。

设置新镜像的引用 (-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