buildx bake does not tag docker-compose images
When I build the images for a compose file, buildx bake will export them, but not tag them. e.g.:
$ docker buildx bake
[…]
$ docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> b8c0f7d34127 About a minute ago 810MB
<none> <none> ebd3ca4c54c5 2 minutes ago 806MB
I can work around this with some jq:
$ docker buildx bake -f <(docker buildx bake -f docker-compose.yml --print | jq --arg name "$(basename "$PWD")" '{group: .group, target: (.target|to_entries|[.[]|{(.key):(.value + {"tags":[$name + "_" + .key]})}]|add)}')
[…]
$ docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
asdf_bsdf latest b8c0f7d34127 2 minutes ago 810MB
asdf_csdf latest ebd3ca4c54c5 3 minutes ago 806MB
and docker-compose will correctly use these images and not try to build them again.
But shouldn't this be done by default?
Misc
$ docker buildx version
github.com/docker/buildx v0.7.1-docker 05846896d149da05f3d6fd1e7770da187b52a247
[Edit]
I suppose I could use x-bake this for that (but then I lose the flexibility of having multiple project names (docker-compose -p) from the same compose file), or --set, which is tedious. I guess that makes this a feature request to
- automatically tag on a folder name derived project-name
- add a cli parameter that allows to override the default project-name
You should set image: in the yaml, even if you don't intend to push the tags. This will then be used as a tag by bake and as the run image by compose (be careful not to up --pull in that case)
Docker-compose build now seems to use buildkit by default (This changed with 2.4.1 for me, but I'm not sure whether that's global or just something weird with my installation.) If someone can confirm that this is global, I think using docker-compose build instead of docker buildx bake is just fine and this can be closed.
(And can we please not make comments like "What the other guy posted fixed it for me too" but just give a 👍 to that comment instead @NadimYounes? I'd like to not receive notifications for that kind of thing…)