Skip to content

Commit 64cf3b0

Browse files
committed
Document how to share services with Docker Compose
Closes gh-37886
1 parent dd821c7 commit 64cf3b0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/docker-compose.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ services:
2626
----
2727

2828
With this Docker Compose file in place, the JDBC URL used is `jdbc:postgresql://127.0.0.1:5432/mydb?ssl=true&sslmode=require`.
29+
30+
31+
32+
[[howto.docker-compose.sharing-services]]
33+
=== Sharing services between multiple applications
34+
35+
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.
36+
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.
37+
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.
38+
You can stop the services manually by running `docker compose stop` on the commandline in the directory which contains the `compose.yaml` file.

0 commit comments

Comments
 (0)