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

Improve detection of docker compose version and syntax #230

Closed
bjoern-arnold opened this issue Jul 25, 2022 · 8 comments
Closed

Improve detection of docker compose version and syntax #230

bjoern-arnold opened this issue Jul 25, 2022 · 8 comments

Comments

@bjoern-arnold
Copy link

#171 introduced a function to detect the version of docker compose and -depending on the determined version- sets the correct command syntax. However, the version detection assumes that the command is still available as "docker-compose"
dockerComposeVersion=$(docker-compose version --short | sed 's~v~~;s~-.*~~')
This is not the case with my installation (Ubuntu 20.04, Docker version 20.10.16, build aa7e414 with docker-compose plugin v2.5.0).
Since Compose V2 went GA in April I suggest to make the new syntax the default for both the dockerCompose variable and the version detection. As a fallback, the old syntax could still be supported by introducing something like:

dockerComposeVersion=$(docker compose version --short | sed 's~v~~;s~-.*~~')
if [ -z $dockerComposeVersion ]; then
  dockerComposeVersion=$(docker-compose version --short | sed 's~v~~;s~-.*~~')
fi
@WadeBarnes
Copy link
Member

WadeBarnes commented Jul 25, 2022

The reason it was not done that way is because the new docker compose command will always return the newer docker compose version even if you are not using it and have it disabled in docker-desktop.

Example:

$ docker compose version --short
2.6.1

$ docker-compose version --short
1.29.2

image


When you select Use Docker Compose V2 docker-compose will return the new version:

image

$ docker-compose version --short
2.6.1

$ docker compose version --short
2.6.1

$ docker version
Client:
 Cloud integration: v1.0.24
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:09:02 2022
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.10.1 (82475)
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

@WadeBarnes
Copy link
Member

@bjoern-arnold, are you able to switch back and forth between the old and new docker-compose versions in your environment, and if so how does it report the version being used?

@bjoern-arnold
Copy link
Author

@WadeBarnes no, I'm not abel to switch versions. I assume it's because I've installed Docker Engine only and the new "docker compose" command does not allow switching versions any more (as described e.g. here). My issue is that there is no "docker-compose" command available any more and thus the manage script fails at line 22

@WadeBarnes
Copy link
Member

In that case it is more appropriate to detect whether the docker-compose command is available on the system first before detecting the version being used.

@WadeBarnes
Copy link
Member

Would you like to give that a try and submit a PR?

@bjoern-arnold
Copy link
Author

@WadeBarnes I'm contributing as a Bosch associate and thus I have to get the project approved by our open source officer. This includes an evaluation of the project repo. He found that your policy requires a CONTRIBUTING.md to be present which is not true for this project (see here). Could you please add this file?

@WadeBarnes
Copy link
Member

Done

@bjoern-arnold
Copy link
Author

Already handled by #239

@bjoern-arnold bjoern-arnold closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
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

No branches or pull requests

2 participants