Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: multiple tags by simply using multiple --tag parameters #396

Closed
jonstelly opened this issue Sep 18, 2020 · 9 comments
Closed

Comments

@jonstelly
Copy link

I had cobbled together a build process using buildx where I ran buildx build ... --push twice (with different tags) so I could build and publish for multiple tags.

docker buildx build . --platform=linux/arm64,linux/amd64 --tag my/image:0.1 --pull --push --no-cache
docker buildx build . --platform=linux/arm64,linux/amd64 --tag my/image:latest

It didn't immediately jump out at me that the --tag parameter could be specified multiple times until I happened to see stringArray as the type for the --tag parameter. This lets me build and push to multiple tags in one step:

docker buildx build . --platform=linux/arm64,linux/amd64 --tag my/image:0.1 --tag my/image:latest --pull --push --no-cache

I'll try and find a minute to add this to the README.md and submit a PR in the next couple days but wanted to capture this as an issue to explain it first.

@timorkal
Copy link

Please +1

@yywing
Copy link

yywing commented Dec 3, 2020

Is it work? My test is not work.
#459

@ksurl
Copy link

ksurl commented Jan 20, 2021

does this work for different registries in the same command? e.g. tag and push to docker hub and github container registry

docker buildx build . --platform=linux/amd64 -t user/image -t ghcr.io/user/image --push

@immanuelfodor
Copy link

Yes, it does, I'm actively using it in my CI to publish to an internal registry and DockerHub simultaneously: https://github.com/immanuelfodor/kube-karp/blob/master/.drone.yml#L59

@crazy-max
Copy link
Member

@dudicoco
Copy link

dudicoco commented Aug 6, 2021

@crazy-max according to the docs --tag accepts a stringArray, however when attempting to pass multiple tags the following error occures:

$ docker buildx build -t latest,test
error: "docker buildx build" requires exactly 1 argument.

It seems that currently it is only possible to pass multiple -t arguments for each tag, even though the docs state otherwise.

Can you please explain this behaviour?

@crazy-max
Copy link
Member

@dudicoco

$ docker buildx build -t latest,test

You need to specify the context and also stringArray stores values as multiple flags compared to a stringSlice which takes comma-separated values:

$ docker buildx build -t latest -t test .

jonstelly added a commit to jonstelly/buildx that referenced this issue Aug 6, 2021
Call out differences between stringSlice and stringArray.  Clarification for docker#396
@jonstelly
Copy link
Author

jonstelly commented Aug 6, 2021

That PR might help clarify the difference?

@dudicoco
Copy link

dudicoco commented Aug 7, 2021

Thanks @crazy-max, the context was missed during copy paste.

So i've encountered another issue with passing tags to the bake command when working with a docker-compose.yaml file.
Since the compose file does not allow to specify multiple tags per service, how can we specify multiple tags without using a docker-bake.json/hcl file?
Passing the tags via flags is not a good option as each target might use a different docker repository, for example:

services:
  app1:
    image: ${DOCKER_REGISTRY:-default}/app1:${TAG:-latest}
    build: app1/
  app2:
    image: ${DOCKER_REGISTRY:-default}/app2:${TAG:-latest}
    build: app2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants