为使用ImageBuild构建的图像设置仓库和标签

答案在帖子底部:

我无法使用docker go sdk client ImageBuild函数设置已构建映像的Repo AND Tag。

func (cli *Client) ImageBuild(ctx context.Context,buildContext io.reader,options types.ImageBuildOptions) (types.ImageBuildResponse,error)

采用结构参数ImageBuildOptions,该参数用于设置各种构建参数。

ImageBuildOptions结构包含属性

Tags []string

将标签设置为一组字符串会为“标签”集中以“ REPO”作为字符串集元素的每个字符串条目生成图像。

我无法找到使用ImageBuildOptions结构的属性来设置回购值的参考。

ImageBuildOptions结构的一个名为ImageBuildOutput

的属性
// Outputs defines configurations for exporting build results. Only supported
// in BuildKit mode
Outputs []ImageBuildOutput

我相信使用ImageBuildOutput结构可能会提供解决方案,但我无法找到有关ImageBuildOutput使用情况的文档

在ImageBuildOptions中,我还尝试了两种方法:

Tags: []string{"/this/is/some/rag"},
Tags: []string{"a",":tag"},

都导致错误

示例:

使用:

Tags: []string{"some","set","of","tags"},

产生4张带标签的图像:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
of                  latest              abfb7311a779        9 minutes ago       464MB
set                 latest              abfb7311a779        9 minutes ago       464MB
some                latest              abfb7311a779        9 minutes ago       464MB
tags                latest              abfb7311a779        9 minutes ago       464MB

我需要能够使用docker go sdk构建映像,以便可以将存储库指定为

this/is/some/repo

,标记为

thistag

生成带有repo:tag为

的构建图像
this/is/some/repo:thistag

编辑:答案:

您需要将实际repo:tag集作为“标签”集的一项传递 所以

Tags: []string{"this/is:something"},

显示图片:

REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
this/is             something           c0606918cc24        About a minute ago   464MB
talang2009 回答:为使用ImageBuild构建的图像设置仓库和标签

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3140302.html

大家都在问