From 64cf3b0712e11d25db5671bdb4a5c676d7afac59 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 19 Oct 2023 10:05:14 +0200 Subject: [PATCH] Document how to share services with Docker Compose Closes gh-37886 --- .../src/docs/asciidoc/howto/docker-compose.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/docker-compose.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/docker-compose.adoc index 7d18533974c..9b59fadc563 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/docker-compose.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/docker-compose.adoc @@ -26,3 +26,13 @@ services: ---- With this Docker Compose file in place, the JDBC URL used is `jdbc:postgresql://127.0.0.1:5432/mydb?ssl=true&sslmode=require`. + + + +[[howto.docker-compose.sharing-services]] +=== Sharing services between multiple applications + +If you want to share services between multiple applications, create the `compose.yaml` file in one of the applications and then use the configuration property configprop:spring.docker.compose.file[] in the other applications to reference the `compose.yaml` file. +You should also set configprop:spring.docker.compose.lifecycle-management[] to `start-only`, as it defaults to `start-and-stop` and stopping one application would shut down the shared services for the other still running applications, too. +Setting it to `start-only` won't stop the shared services on application stop, but a caveat is that if you shut down all applications, the services stay running. +You can stop the services manually by running `docker compose stop` on the commandline in the directory which contains the `compose.yaml` file.