gradle-docker-compose-plugin
gradle-docker-compose-plugin copied to clipboard
Use 'docker compose' instead of 'docker-compose'
Have you considered porting this to use the new compose functionality in the Docker daemon?
Thank you.
Hello, it would be nice to support both Docker Compose 1.x and V2 but unfortunately I don't have time for this improvement now. Any help welcome 🙏
Can this be used as a workaround?
$ echo '#!/usr/bin/env bash
docker compose $@' > ~/bin/docker-compose
$ chmod 755 ~/bin/docker-compose
$ which docker-compose
/Users/me/bin/docker-compose
$ docker-compose version
Docker Compose version v2.3.3
Alternatively uninstall the regular docker-compose and just do ...
ln -s $HOME/.docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
... or similarily on macOS:
ln -s /Applications/Docker.app/Contents/Resources/cli-plugins/docker-compose /usr/local/bin/docker-compose
I've tried to add support in the PR at #348. Might be too simplistic, but at least shouldn't break anything with the default config.
@henrik242 Actually, there is compose-switch
utility that works like a bridge between docker-compose
and docker compose
: https://github.com/docker/compose-switch/
@stewartbryson @henrik242 What is please your use-case for docker compose
usage? According to the docs:
So the aliasing should still work, so there shouldn't be any reason for docker compose
support 🤔
compose-switch
requires a separate install, which we'd rather not have to push on all users of our project.
The default bundled docker-compose
in Docker Desktop is v1.29.2 from may 2021, and doesn't support the latest compose-spec
$ ls -l /usr/local/bin/docker-compose
lrwxr-xr-x 1 root admin 62 25 aug 2021 /usr/local/bin/docker-compose -> /Applications/Docker.app/Contents/Resources/bin/docker-compose
$ ls -l /usr/local/bin/docker
lrwxr-xr-x 1 root admin 54 17 nov 2020 /usr/local/bin/docker -> /Applications/Docker.app/Contents/Resources/bin/docker
$ /usr/local/bin/docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h 22 Sep 2020
$ /usr/local/bin/docker compose version
Docker Compose version v2.3.3
I didn't mean compose-switch
as replacement for a feature of this plugin, I just wanted to mention it as an alternative for the solution proposed by you 👌
Imagine we introduced the proposed ComposeV2
switch - then if enabled, you would have to force all the users of your project to switch to a latest version of Docker Desktop that supports docker compose
.
What would be the perfect solution would be not to introduce the ComposeV2
switch at all, but make the decision internally, if use docker-compose
or docker compose
. But I'm not sure how to detect that Compose V2 should be used 🤔
You could of course check versions of both docker-compose
and docker compose
and pick the latest one, but debugging errors could be tricky if the user is not aware of what is happening.
I'd rather have a manual switch for now.
I just had to spend some extra time making this work as "docker-compose" is not an official alias for "docker compose" in the main installation.
Could there be a config variable saying "useComposeV2" that can, eventually, have its default set to true? That'd require maintaning both codes for a little while, though.
Our docker-compose version switched from 1.29.2 to 2.10.2 on our build images and we are getting invalid tag reference names due to the service name prefixes changing to -
to _
in our CI environment.
> Task :composeBuild FAILED
invalid tag "6a186a353405cef76803929dcf99538d_ads-decision-engine_-localstack": invalid reference format
FAILURE: Build failed with an exception.
Anyone have a workaround that works with the new docker-compose version 2 or do I need to get the platform team to revert the docker-compose version?
If anyone comes across the above issue, the workaround is to set the following env var COMPOSE_COMPATIBILITY=1
which restores the v1 service name prefix.
Looks like the time is coming soon: warnings in the latest update of docker desktop.
https://docs.docker.com/compose/migrate/
Thanks. Feel free to prepare a new PR for this feature 🙏
we also can take a look at the continiously supported solution from the latest spring-boot 3.1 org.springframework.boot:spring-boot-docker-compose https://tpbabparn.medium.com/spring-boot-3-1-integrated-docker-compose-on-development-environment-spring-webflux-example-1ddcbfe052f
Won't this tie you to the Spring eco system? The nice thing of the avast gradle-docker-compose-plugin for me is that it is quite standalone and has a clear boundary between code and Docker, with Spring it usually gets blurry and/or you need many dependencies.
As a workaround we created a fake docker-compose
script.
#!/bin/sh
/usr/bin/docker compose "$@"
@rt-works You shouldn't quote $@
worked for me with quoting
@rt-works For simple commands, yeah. With more options it might not.
Good to know :) For the "up -f docker-compose.yaml" which is passed there by gradle plugin that was sufficient.
For those interested, I've opened a PR to add this feature to the plugin. If anyone has time to do additional testing or to review, it would be much appreciated.
Fixed by #410