Buildkit: Docker exporter - specify multiple tags during build

Created on 24 Jan 2019  路  16Comments  路  Source: moby/buildkit

Hi,

Is it possible to specify more than one name during docker build like docker cli does:

docker build -t name:tag1 -t name:tag2

enhancement help wanted

Most helpful comment

@giulioprovasi 2'nd name just overrides 1'st name, this is not what we need.

--output type=image,"name=username/image:tag1,username/image:tag2"

as specified by @thaJeztah, works for me as expected. I have to escape quotes as mentioned, my Gitlab-CI script part is following

--output type=image,\"name=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA,$CI_REGISTRY_IMAGE:${IMG_TAG}\",push=true

All 16 comments

It's not available atm but should be easy to add if there is a need.

I have the occasional need for this.
Saves me doing tag afterwards.

@tonistiigi I would like to work on this request. Where should I be starting with this? any pointers?

The image exporter supports multiple names with a comma separated list, added in #561. @hpandeycodeit You could add the same support to oci exporter (docker and oci variant share the implementation). Split the name into an array like in #561 , and modify https://github.com/moby/buildkit/blob/master/exporter/oci/export.go#L198 to take an array of names instead of a single one.

@tonistiigi wondering; will it be possible to specify multiple targets? (Think I wrote a proposal for that somewhere); ie, tag multiple targets (stages)?

@thaJeztah No, multiple builds for multiple targets. This issue is about tags.

I'd like that too

@tonistiigi What is the correct syntax for this? I tried:

--output type=image,name=username/image:tag1,username/image:tag2
````
And I get:

error: invalid value username/image:tag2
```

Probably you need to quote the string

No that doesn't help, seems like this only works with the old --exporter syntax.

Because of the csv reader you need to quote the values with commas and make sure your shell does not interpret them.

^^ for the CSV, the quotes should be around the names=xx,xx,xx because that's a single "field" in the CSV, so;

--output type=image,"name=username/image:tag1,username/image:tag2"

(possibly with escaping the quote if needed to take the shell into account, as mentioned above)

@thaJeztah @tonistiigi I am facing the same issue that @sethpollack have.
It works using the deprecated --exporter-opt but not using --output
Do you have a working example ?

I found out that the right syntax (in master branch) is the following:

--output type=image,name=username/image:tag1,name=username/image:tag2,push=true

@giulioprovasi 2'nd name just overrides 1'st name, this is not what we need.

--output type=image,"name=username/image:tag1,username/image:tag2"

as specified by @thaJeztah, works for me as expected. I have to escape quotes as mentioned, my Gitlab-CI script part is following

--output type=image,\"name=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA,$CI_REGISTRY_IMAGE:${IMG_TAG}\",push=true
Was this page helpful?
0 / 5 - 0 ratings