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

Checks if docker compose or docker-compose is installed #409

Merged
merged 1 commit into from
May 18, 2022

Conversation

affektde
Copy link
Contributor

This commit introduced a new error for our Laravel Sail installation: 1da083e#commitcomment-73871145

In my comment I've explained the issue.

This pull request and change contains another approach to determine if docker compose or docker-compose is installed.

As in my comment described command -v docker compose outputs two lines and not just one installation PATH from docker compose.

command -v docker compose
/usr/bin/docker
/usr/bin/compose

Maybe there is a better bash expression but this is working for me:

docker compose &> /dev/null
if [ $? == 0 ]; then
...

I've testet it with

sudo apt-get install docker-compose-plugin

=> uses docker compose

sudo apt-get remove docker-compose-plugin

=> uses docker-compose

@jessarcher
Copy link
Member

jessarcher commented May 18, 2022

Thanks, @affektde!

I'm seeing a related issue when docker-compose-plugin is not installed. The call to command -v docker compose returns a single line regardless of whether docker-compose-plugin is installed, again due to the space. This results in the following when calling sail:

docker: 'compose' is not a docker command.

Your solution works for me. It's a shame to have the overhead of executing docker compose to check for a non-zero exit, but I can't think of a better way. The check is very fast, both with and without the plugin installed.

The docker-compose-plugin is also significantly faster than docker-compose, so I'm keen on anything we can do to favour it.

@taylorotwell taylorotwell merged commit f00f3a8 into laravel:1.x May 18, 2022
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.

3 participants