buildx icon indicating copy to clipboard operation
buildx copied to clipboard

How can I append tags with --set ?

Open back-2-95 opened this issue 4 years ago • 5 comments

I have target like:

target "fpm-73" {
  ...
  tags = ["repo/php:7.3-fpm", "repo/php:7.3-fpm-latest"]
}

I'm getting Minor version outside of docker-bake.hcl, e.g. 7.3.27 so I'd like to append a tag to the target tags:

docker buildx bake --print --pull --push --set fpm-73.tags=repo/php:7.3.27

Now with that ^^ the tags list from hcl file gets overriden totally.

back-2-95 avatar Jun 13 '21 15:06 back-2-95

Got around this with:

PHP_MINOR_VERSION=7.3.27 docker buildx bake --print --pull --push

And in docker-bake.hcl:

variable PHP_MINOR_VERSION {}

target "fpm-73" {
  ...
  tags = ["repo/php:7.3-fpm", "repo/php:${PHP_MINOR_VERSION}-fpm-latest", "repo/php:7.3-fpm-latest"]
}

back-2-95 avatar Jun 14 '21 09:06 back-2-95

I don't think this is currently possible. We've discussed things like --set fpm-73.tags+=repo/php:7.3.27

tonistiigi avatar Jun 14 '21 19:06 tonistiigi

We've discussed things like --set fpm-73.tags+=repo/php:7.3.27

Personally I find mini-languages in flags a bit over the top, --set flag is already complex enough. Using HCL variables seems like a viable solution.

errordeveloper avatar Dec 17 '21 15:12 errordeveloper

Yeah, I have been quite happy with HCL variable thing there ^^ It also reminds passing args to Dockerfile.

back-2-95 avatar Dec 18 '21 07:12 back-2-95

Related to https://github.com/docker/buildx/issues/901?

thompson-shaun avatar Jun 20 '24 17:06 thompson-shaun

I took a look at this one and it seems for entitlements, annotations and attest attributes we already append: https://github.com/docker/buildx/blob/921b576f3a26a93dbe5640fe34f421e5fb3fa83c/bake/bake.go#L963-L979. In such case += is already the default for these attributes. Making them an actual override would be a breaking change :thinking:

Like:

		case "annotations":
			if o.Append {
				t.Annotations = append(t.Annotations, o.ArrValue...)
			} else {
				t.Annotations = o.ArrValue
			}

crazy-max avatar Feb 27 '25 16:02 crazy-max