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

r.sh should warn when docker-compose is missing #207

Conversation

nicolaiskogheim
Copy link

Why:

  • The docker-compose command is required to run r.sh, because it calls docker compose, which uses the docker-compose command.
  • The error when docker-compose is missing is unintelligible:
    $ docker compose --env-file ...
    unknown flag: --env-file
    See 'docker --help'.
    ...
    

This change addresses the need by:

  • Checking for the presence of docker-compose and informing the user to install it.

Tested on Manjaro Linux. I don't know if docker/docker-compose is packaged differently on MacOS, so this should be tested there.

Why:

* The `docker-compose` command is required to run `r.sh`, because it
  calls `docker compose`, which uses the `docker-compose` command.
* The error when `docker-compose` is missing is unintelligible:
  ```
  $ docker compose --env-file ...
  unknown flag: --env-file
  See 'docker --help'.
  ...
  ```

This change addresses the need by:

* Checking for the presence of docker-compose and informing the user to
  install it.
@Rathios
Copy link

Rathios commented Oct 16, 2024

Hi and thank you for the PR.

docker compose and docker-compose don't always both exist. E.g. on Ubuntu 24.04 you can install the Docker Compose plugin without having the old docker-compose installed (which is deprecated).

I recommend something OS agnostic that checks for both:

if docker compose > /dev/null 2>&1; then
  compose_cmd="docker compose"
elif command -v docker-compose; then
  compose_cmd="docker-compose"
else
  echo "Error: Docker Compose is not installed. Please install it and try again."
  exit 1
fi
$compose_cmd up openldap dex init-dex-db vault mongodb rabbitmq mongo-express redis ms-auth ms-kind ms-talos $@

More info here: https://stackoverflow.com/questions/66514436/difference-between-docker-compose-and-docker-compose

@havardelnan
Copy link
Collaborator

havardelnan commented Oct 18, 2024

Hi and thx for the pr.

As described in https://docs.docker.com/compose/releases/migrate/#:~:text=From%20July%202023%20Compose%20V1,supported%20versions%20of%20Docker%20Desktop.

docker-compose is the deprecated v1 implementation of "docker compose" and "docker compose" is the v2 implementation.

So maybe a third option running

$ docker-compose version --short 
1.29.2

$ docker compose version --short
2.29.1

aka

if docker compose > /dev/null 2>&1; then
  compose_cmd="docker compose"
elif command -v docker-compose; then
  compose_cmd="docker-compose"
else
  echo "Error: Docker Compose is not installed. Please install it and try again."
  exit 1
fi
version=$($compose_cmd version --short | cut -d "." -f 1)
if [ "$version" -lt 2 ]; then
    echo "Docker Compose version is to low, needs to be v2.0.0 or higher."
    exit 1
fi

$compose_cmd up openldap dex init-dex-db vault mongodb rabbitmq mongo-express redis ms-auth ms-kind ms-talos $@

@havardelnan
Copy link
Collaborator

#290 will fix, sorry for the long wait

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