From de1ca5e60ff1936fa1d780c46b61cb4bb7229b4a Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 31 Oct 2023 11:18:39 +0100 Subject: [PATCH 1/2] Polish DockerComposeLifecycleManager --- .../compose/lifecycle/DockerComposeLifecycleManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java index 4fbf7b1b63d..b73a9d40d48 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java @@ -121,7 +121,9 @@ class DockerComposeLifecycleManager { if (lifecycleManagement.shouldStart() && runningServices.isEmpty()) { start.getCommand().applyTo(dockerCompose, start.getLogLevel()); runningServices = dockerCompose.getRunningServices(); - wait = (wait != Wait.ONLY_IF_STARTED) ? wait : Wait.ALWAYS; + if (wait == Wait.ONLY_IF_STARTED) { + wait = Wait.ALWAYS; + } if (lifecycleManagement.shouldStop()) { this.shutdownHandlers.add(() -> stop.getCommand().applyTo(dockerCompose, stop.getTimeout())); } From 87d6d518c405fb428dfb46a6878498aff7107ee7 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 31 Oct 2023 11:18:56 +0100 Subject: [PATCH 2/2] Explain what happens if docker compose is already running Closes gh-36483 --- .../src/docs/asciidoc/features/docker-compose.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/docker-compose.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/docker-compose.adoc index d91dec90024..935d8685844 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/docker-compose.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/docker-compose.adoc @@ -28,6 +28,8 @@ Add the module dependency to your build, as shown in the following listings for } ---- +NOTE: The `docker compose` or `docker-compose` CLI application needs to be on your path in order for Spring Boot’s support to work correctly. + When this module is included as a dependency Spring Boot will do the following: * Search for a `compose.yml` and other common compose filenames in your application directory @@ -35,7 +37,8 @@ When this module is included as a dependency Spring Boot will do the following: * Create service connection beans for each supported container * Call `docker compose stop` when the application is shutdown -NOTE: The `docker compose` or `docker-compose` CLI application needs to be on your path in order for Spring Boot’s support to work correctly. +If the Docker Compose services are already running when starting the application, Spring Boot will only create the service connection beans for each supported container. +It will not call `docker compose up` again and it will not call `docker compose stop` when the application is shutdown. NOTE: By default, Spring Boot's Docker Compose support is disabled when running tests. To enable it, set configprop:spring.docker.compose.skip.in-tests[] to `false`.