-
Notifications
You must be signed in to change notification settings - Fork 96
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
Support ComposeV2 #339
Support ComposeV2 #339
Conversation
docker-compose v2 returns an exit code of 1 when running ps on a non-existent container, when v1 returned 0 and an empty list.
docker-compose v2 starts containers that depend on failed containers. This may be considered a bug or a feature. Either way, the only way to recover is to bring all containers down.
docker-compoose config doesn't always include the version number from the original configuration, so this can't be reliably used to know whether the services are under the services key or directly under the root.
docker-compose v2 now names containers in the form: ${container_id}_${name}-\d+ Previously, it used an underscore after the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this PR, awesome! 👍
I have just few minor notes.
src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy
Outdated
Show resolved
Hide resolved
src/test/groovy/com/avast/gradle/dockercompose/CaptureOutputTest.groovy
Outdated
Show resolved
Hide resolved
docker-compose ps returns an exit code of 1 when a named service doesn't exist. Rather than trying to work out why the exit code is 1, get the service list first to see whether it's worth running ps with a service name.
Test that uotput from containers is captured by doccker-compose. v2 strangely strips newlines in certain circumstances.
Thank you very much for your contribution! 👍 I tried it locally on a few real-world projects and it works like a charm, so I'm going to release this change in |
Great! Thanks for your help with this. 😄 |
This is primarily to pick up support for docker compose v2 output, avast/gradle-docker-compose-plugin#339. Note: the plugin still requires `docker-compose` (see avast/gradle-docker-compose-plugin#322). In my case, I was able to simply proxy via bash to `docker compose`: ``` $ cat ~/.local/bin/docker-compose docker compose $@ ``` There may be more official ways to create this shim layer.
This is primarily to pick up support for docker compose v2 output, avast/gradle-docker-compose-plugin#339. Note: the plugin still requires `docker-compose` (see avast/gradle-docker-compose-plugin#322). In my case, I was able to simply proxy via bash to `docker compose`: ``` $ cat ~/.local/bin/docker-compose #!/usr/bin/env bash docker compose $@ ``` https://github.com/docker/compose-switch/ may be the "official" way to redirect docker-compose, but I haven't looked into it.
docker-compose
version 2 introduces a few subtle changes that the Gradle plugin needs updating to cope with:The key one (and the one we noticed first) is the container name separator change from
_
to-
, e.g.:dc0d8ebebfc1bd2d95a03ae408b9320f_test__fail_1
vs.8a14f97d108b86c6af4af2a05bff880f_test_-fail-1
). This stopped the plugin parsing the container names and setting the environment variables${serviceName}_HOST
, etc.docker-compose ps
now exits with code 1 when the container doesn't exist (instead of outputting an empty list.ComposeV2 removes support for unversioned configuration files.
Tested with
docker-compose
1.29.2 and 2.2.3 on an Intel Mac.