spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Conflict between org.springframework.cloud:spring-cloud-starter-bootstrap and org.springframework.boot:spring-boot-docker-compose

Open Fachher opened this issue 6 months ago • 1 comments

After adding spring-cloud-starter-bootstrap to my project, spring-boot-docker-compose is unable to locate docker compose file anymore.

I have added an minimal reproducible example project with two commits. First commit is an working example while the second commit leads to the mentioned problem. Just start the application.

https://github.com/Fachher/spring-cloud-issue

What I have found out so far.

org.springframework.boot.docker.compose.lifecycle.DockerComposeListener is executed before org.springframework.boot.env.EnvironmentPostProcessorApplicationListener after adding 'spring-cloud-starter-bootstrap'.

Therefore org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties is uninitialized during the execution of DockerComposeListener.

If a custom value is set for spring.docker.compose.file in application.yml it is ignored.

If I provide the location of the docker compose file via environment variable (SPRING_DOCKER_COMPOSE_FILE=foo/bar/docker-compose.yml), it is working properly.

Fachher avatar Jun 19 '25 06:06 Fachher

Additional information on how to reproduce.

Just start the application by calling ./gradlew bootRun

It will ignore property spring.docker.compose.file: etc/docker/docker-compose.yml

java.lang.IllegalStateException: No Docker Compose file found in directory '/Users/foobar/Projects/spring-cloud-issue/.' at org.springframework.util.Assert.state(Assert.java:101) ~[spring-core-6.2.7.jar:6.2.7] at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.getComposeFile(DockerComposeLifecycleManager.java:153) ~[spring-boot-docker-compose-3.4.6.jar:3.4.6] at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.start(DockerComposeLifecycleManager.java:111) ~[spring-boot-docker-compose-3.4.6.jar:3.4.6] at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:53) ~[spring-boot-docker-compose-3.4.6.jar:3.4.6] at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:35) ~[spring-boot-docker-compose-3.4.6.jar:3.4.6] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:98) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.SpringApplicationRunListeners.lambda$contextLoaded$4(SpringApplicationRunListeners.java:72) ~[spring-boot-3.4.6.jar:3.4.6] at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:72) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:416) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:317) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:198) ~[spring-cloud-context-4.3.0.jar:4.3.0] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:114) ~[spring-cloud-context-4.3.0.jar:4.3.0] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:77) ~[spring-cloud-context-4.3.0.jar:4.3.0] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-6.2.7.jar:6.2.7] at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136) ~[spring-boot-3.4.6.jar:3.4.6] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81) ~[spring-boot-3.4.6.jar:3.4.6]

Fachher avatar Nov 04 '25 16:11 Fachher