diff --git a/bin/docker-compose b/bin/docker-compose index 8aa21b9..aaa65b7 100755 --- a/bin/docker-compose +++ b/bin/docker-compose @@ -159,12 +159,22 @@ function print_debug_info() { fi } -function run_docker_compose() { - exec docker-compose -p "$PROJECT_NAME" "${DOCKER_COMPOSE_FLAGS[@]}" "$@" +function docker_compose() { + local flags=(-p "$PROJECT_NAME" "${DOCKER_COMPOSE_FLAGS[@]}" "$@") + if docker compose version >/dev/null 2>&1; then + # Docker compose v2 is available + exec docker compose "${flags[@]}" + elif command -v docker-compose >/dev/null; then + # Fall back to docker-compose v1 + exec docker-compose "${flags[@]}" + else + echo "ERROR: Could not find Docker Compose." >&2 + exit 1 + fi } read_image_version read_config build_environment print_debug_info "$@" -run_docker_compose "$@" +docker_compose "$@" diff --git a/bin/doctor b/bin/doctor index 9cbe424..3698140 100755 --- a/bin/doctor +++ b/bin/doctor @@ -113,7 +113,6 @@ function check_dependencies() { declare -a binaries=( bash docker - docker-compose realpath perl awk @@ -123,6 +122,16 @@ function check_dependencies() { for binary in "${binaries[@]}"; do check_for_binary "$binary" done + + if docker compose version > /dev/null 2>&1; then + print_point 1 "docker compose" + print_point 2 "status: present" + print_point 2 "version info: $(docker compose version)" + elif command -v docker-compose > /dev/null; then + check_for_binary docker-compose + else + add_warning "Docker Compose not found" + fi } function check_docker_daemon() { diff --git a/bin/up b/bin/up index 3d86159..99317b8 100755 --- a/bin/up +++ b/bin/up @@ -21,9 +21,9 @@ source "$TOOLKIT_ROOT/lib/shared-functions.sh" function usage() { echo "Usage: bin/up [FLAGS...]" echo "" - echo "A wrapper around 'docker-compose up'." + echo "A wrapper around 'docker compose up'." echo "" - echo "This program will pass any extra flags to docker-compose," + echo "This program will pass any extra flags to docker compose," echo "for example: 'bin/up -d' will run in detached mode" } diff --git a/doc/configuration.md b/doc/configuration.md index 558e4a8..5e40229 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -11,7 +11,7 @@ This directory is excluded from the git revision control system, so it will not Note that changes to the configuration files will not be automatically applied to existing containers, even if the container is stopped and restarted (with `bin/stop` and `bin/start`). To apply the changes, run `bin/up`, and -`docker-compose` will automatically apply the configuration changes to a new +`docker compose` will automatically apply the configuration changes to a new container. (Or, run `bin/up -d`, if you prefer to not attach to the docker logs) @@ -53,6 +53,6 @@ The `config/version` file contains the version number of the docker images that ## The `docker-compose.override.yml` File -If present, the `config/docker-compose.override.yml` file will be included in the invocation to `docker-compose`. This is useful for overriding configuration specific to docker-compose. +If present, the `config/docker-compose.override.yml` file will be included in the invocation to `docker compose`. This is useful for overriding configuration specific to docker compose. See the [docker-compose documentation](https://docs.docker.com/compose/extends/#adding-and-overriding-configuration) for more details. diff --git a/doc/dependencies.md b/doc/dependencies.md index d952045..463bb38 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -1,7 +1,7 @@ # Dependencies This project requires a modern unix system as a base (such as Ubuntu Linux). -It also requires `bash`, `docker`, and `docker-compose`. +It also requires `bash` and `docker`. The `bin/doctor` script can be used to check for missing dependencies. diff --git a/doc/docker-compose.md b/doc/docker-compose.md index 7865a44..7f15814 100644 --- a/doc/docker-compose.md +++ b/doc/docker-compose.md @@ -1,8 +1,8 @@ -# Working with Docker-Compose Services +# Working with Docker Compose Services The Overleaf Toolkit runs Overleaf inside a docker container, plus the supporting databases (MongoDB and Redis), in their own containers. All of this -is orchestrated with `docker-compose`. +is orchestrated with `docker compose`. Note: for legacy reasons, the main Overleaf container is called `sharelatex`, and is based on the `sharelatex/sharelatex` docker image. This is because the @@ -15,12 +15,12 @@ Overleaf naming scheme. ## The `bin/docker-compose` Wrapper -The `bin/docker-compose` script is a wrapper around `docker-compose`. It +The `bin/docker-compose` script is a wrapper around `docker compose`. It loads configuration from the `config/` directory, before invoking -`docker-compose` with whatever arguments were passed to the script. +`docker compose` with whatever arguments were passed to the script. You can treat `bin/docker-compose` as a transparent wrapper for the -`docker-compose` program installed on your machine. +`docker compose` program installed on your machine. For example, we can check which containers are running with the following: diff --git a/doc/overview.md b/doc/overview.md index 2d77c3a..dc989b0 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -18,9 +18,9 @@ Community Edition is the free version of Overleaf, while Server Pro is our enter When you set up Overleaf using the toolkit, you will start with Community Edition, and can easily switch to Server Pro by changing just one setting. -## Docker, Docker-Compose, and Overleaf +## Docker, Docker Compose, and Overleaf -The toolkit uses [Docker](https://www.docker.com) and [Docker-Compose](https://docs.docker.com/compose/) to run the Overleaf software in an isolated sandbox. While we do recommend becoming familiar with both Docker and Docker-Compose, we also aim to make it as easy as possible to run Overleaf on your own computer. +The toolkit uses [Docker](https://www.docker.com) and [Docker Compose](https://docs.docker.com/compose/) to run the Overleaf software in an isolated sandbox. While we do recommend becoming familiar with both Docker and Docker Compose, we also aim to make it as easy as possible to run Overleaf on your own computer. ## How do I get the Toolkit? diff --git a/doc/quick-start-guide.md b/doc/quick-start-guide.md index 96fbe79..7081f98 100644 --- a/doc/quick-start-guide.md +++ b/doc/quick-start-guide.md @@ -6,10 +6,9 @@ The Overleaf Toolkit depends on the following programs: - bash - docker -- docker-compose -We recommend that you install the most recent version of docker and docker-compose that -are available on your system. +We recommend that you install the most recent version of docker that is +available on your system. ## Install @@ -78,7 +77,7 @@ These are the three configuration files you will interact with: ## Starting Up -The Overleaf Toolkit uses `docker-compose` to manage the overleaf docker containers. The toolkit provides a set of scripts which wrap `docker-compose`, and take care of most of the details for you. +The Overleaf Toolkit uses `docker compose` to manage the overleaf docker containers. The toolkit provides a set of scripts which wrap `docker compose`, and take care of most of the details for you. Let's start the docker services: @@ -87,7 +86,7 @@ $ bin/up ``` You should see some log output from the docker containers, indicating that the containers are running. -If you press `CTRL-C` at the terminal, the services will shut down. You can start them up again (without attaching to the log output) by running `bin/start`. More generally, you can run `bin/docker-compose` to control the `docker-compose` system directly, if you find that the convenience scripts don't cover your use-case. +If you press `CTRL-C` at the terminal, the services will shut down. You can start them up again (without attaching to the log output) by running `bin/start`. More generally, you can run `bin/docker-compose` to control the `docker compose` system directly, if you find that the convenience scripts don't cover your use-case. ## Create the first admin account @@ -162,9 +161,6 @@ We should see some output similar to this: - docker - status: present - version info: Docker version 19.03.6, build 369ce74a3c - - docker-compose - - status: present - - version info: docker-compose version 1.24.0, build 0aa59064 ... ====== Configuration ====== ...