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

Support ComposeV2 #339

Merged
merged 8 commits into from
Jan 26, 2022
Merged

Support ComposeV2 #339

merged 8 commits into from
Jan 26, 2022

Conversation

simondwilliams
Copy link
Contributor

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.

Simon Williams added 5 commits January 25, 2022 13:12
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.
Copy link
Member

@augi augi left a 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.

Simon Williams added 3 commits January 25, 2022 16:33
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.
@augi augi merged commit 56bd6ab into avast:main Jan 26, 2022
@augi
Copy link
Member

augi commented Jan 26, 2022

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 0.15.0 🎉

@simondwilliams
Copy link
Contributor Author

Great! Thanks for your help with this. 😄

devinrsmith added a commit to devinrsmith/deephaven-core that referenced this pull request Jan 9, 2023
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.
devinrsmith added a commit to deephaven/deephaven-core that referenced this pull request Jan 11, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants