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.
I think the issue is that --output uses a csv reader https://github.com/moby/buildkit/blob/f7cf4823f71b1a43b9911d4ee11f0eb502b54cc8/cmd/buildctl/build/output.go#L20
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
Most helpful comment
@giulioprovasi 2'nd
namejust overrides 1'st name, this is not what we need.as specified by @thaJeztah, works for me as expected. I have to escape quotes as mentioned, my Gitlab-CI script part is following