moodlehq / moodle-docker

A docker environment for moodle developers
GNU General Public License v3.0
373 stars 244 forks source link

Compose Version Detection WSL Docker Desktop #215

Closed NickLambellGCH closed 2 years ago

NickLambellGCH commented 2 years ago

Hi Team,

Each time I run moodle-docker-compose I am prompted with "Compose v2 is not available in Docker CLI, falling back to use docker-compose script". This appears to be due to the check at moodle-docker-compose#L29 checking that the version starts with v2 whereas my result from docker compose version --short is 2.6.0 with no leading v. I'm not sure if this is the case for a standalone Docker installation as I'm running this on WSL2 (Ubuntu 20.04.4) under windows 10 with Docker Desktop providing Docker via their WSL Integration.

scara commented 2 years ago

Hi @NickLambellGCH,

whereas my result from docker compose version --short is 2.6.0 with no leading v

Docker Compose exists into two flavours:

The version of the supported Docker Compose file version is unrelated to the CLI command version.

That being said, it looks like you are actually running v2 since you're running docker compose version and not docker-compose version i.e. w/o the dash.

https://www.docker.com/blog/announcing-compose-v2-general-availability/ tells:

When is Compose V2 GA and what does it mean?

April 26, 2022 marks the GA of Docker Compose V2. Starting today, Compose V2 is the standard across all documentation, and Compose V2 will become the developer default on Docker Desktop. However, you can continue aliasing docker-compose to docker compose and opt-out of V2 via the Docker Desktop UI — or by entering the docker-compose disable-v2 command.

What do I need to do as a developer?

In most cases, you won’t need to do anything. Docker Desktop versions 3.4+ have Compose V2 installed automatically. On Docker Desktop version 4.4.2+, we enable aliasing of docker-compose syntax to docker compose by default. This lets you use V2 as a drop-in replacement for V1 while requiring minimal (if any) updates to your scripts.

https://github.com/docker/compose/blob/9054f6a18b51ff4b7eb5ca669275eceaf9cdc12d/cmd/compose/version.go#L54-L64 actually tells that --short will remove the leading v.

Could you report here the output of the following commands on your environment:

?

/cc @kabalin

TIA, Matteo

NickLambellGCH commented 2 years ago

Hi @scara,

Thanks for the quick reply! On my environment I get the following:

After posting this earlier I created a fork with detection for my version format just to test and it has been running all day without any troubles, https://github.com/moodlehq/moodle-docker/compare/master...NickLambellGCH:master.

scara commented 2 years ago

Hi @NickLambellGCH, thanks for your reply.

Would you mind to create a PR based on your https://github.com/moodlehq/moodle-docker/compare/master...NickLambellGCH:master which IMHO should be improved to just test $ver =~ ^2 since the first output is trashed to check for the availability of v2 and it actually uses the output from the short option?

TIA, Matteo

kabalin commented 2 years ago

Thanks for reporting @NickLambellGCH, in my case the output is:

1000 ruslan@debian:~> docker compose version --short
v2.2.3

We should improve regex to consider v as optional (=~ ^v?2 or the way you suggested), feel free to send PR.

scara commented 2 years ago

We should improve regex to consider v as optional ( =~ ^v?2 or the way you suggested), feel free to send PR.

+1

For the record: https://github.com/docker/compose/commit/99cd90a4b2f129e794fd34d0cf699078bbc2161b i.e. short option changed since 2.3.0: https://github.com/docker/compose/pull/9096.

NickLambellGCH commented 2 years ago

Hey all, I've gone ahead and submitted #216 to resolve this. Thanks for the discussion and feedback.