If an application includes a dependency on spring-boot-docker-compose
but a compose YAML file is not found, app startup fails with a message that does not make the root cause very clear. The error message should make it more clear that a file was not found in the expected location.
2023-05-09T23:11:16.536Z INFO 1 --- [ main] .s.b.d.c.l.DockerComposeLifecycleManager : Found docker compose file 'null'
2023-05-09T23:11:16.636Z ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.boot.docker.compose.core.DockerProcessStartException: Unable to start docker process. Is docker correctly installed?
at org.springframework.boot.docker.compose.core.DockerCli.getDockerCommand(DockerCli.java:75) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.core.DockerCli.<init>(DockerCli.java:62) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.core.DockerCompose.get(DockerCompose.java:101) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.getDockerCompose(DockerComposeLifecycleManager.java:132) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.startup(DockerComposeLifecycleManager.java:103) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:53) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:35) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:98) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplicationRunListeners.lambda$contextLoaded$4(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at java.base/java.lang.Iterable.forEach(Unknown Source) ~[na:na]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:415) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[spring-boot-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.example.books.server.BooksApplication.main(BooksApplication.java:26) ~[classes/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[workspace/:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[workspace/:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[workspace/:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[workspace/:na]
Caused by: org.springframework.boot.docker.compose.core.ProcessStartException: Unable to start command docker version --format {{.Client.Version}}
at org.springframework.boot.docker.compose.core.ProcessRunner.startProcess(ProcessRunner.java:115) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.core.ProcessRunner.run(ProcessRunner.java:87) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.core.ProcessRunner.run(ProcessRunner.java:74) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
at org.springframework.boot.docker.compose.core.DockerCli.getDockerCommand(DockerCli.java:70) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
... 30 common frames omitted
Caused by: java.io.IOException: Cannot run program "docker": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(Unknown Source) ~[na:na]
at java.base/java.lang.ProcessBuilder.start(Unknown Source) ~[na:na]
at org.springframework.boot.docker.compose.core.ProcessRunner.startProcess(ProcessRunner.java:105) ~[spring-boot-docker-compose-3.1.0-SNAPSHOT.jar:3.1.0-SNAPSHOT]
... 33 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) ~[na:na]
at java.base/java.lang.ProcessImpl.<init>(Unknown Source) ~[na:na]
at java.base/java.lang.ProcessImpl.start(Unknown Source) ~[na:na]
... 36 common frames omitted
Comment From: Nick-Wunderdog
Also SB 3.1 is using the obsolete "docker-compose", not the new "docker compose".
Comment From: scottfrederick
SB 3.1 is using the obsolete "docker-compose", not the new "docker compose".
No, it's not. It will try docker compose
first, and fall back to docker-compose
if the former does not work.
Comment From: zt1115798334
你们是怎么解决的,我也遇到这个问题了
Comment From: digiron
For me, its throwing a org.springframework.boot.docker.compose.core.DockerOutputParseException: Failed to parse docker JSON:
Comment From: wilkinsona
Which versions of Docker and Docker Compose are you using, @digiron?
Comment From: yurets1
Какие версии Docker и Docker Compose вы используете, @digiron?
docker -v Docker version 20.10.21, build 20.10.21-0ubuntu3
docker-compose -v docker-compose version 1.29.2, build unknown
Comment From: yurets1
Для меня это создает
org.springframework.boot.docker.compose.core.DockerOutputParseException: Failed to parse docker JSON:
did you solve this problem?
Comment From: wilkinsona
@yurets1 You should upgrade to Docker Compose v2. v1 is no longer receiving updates.
Comment From: yurets1
@yurets1 Вы могли бы перейти на Docker Compose v2. версия v1 больше не получает обновлений.
unfortunately same error(
Comment From: wilkinsona
Then please open a new issue with details of your docker
and docker compose
versions, a minimal sample that reproduces the problem, and the complete error.
Comment From: jordikop
java.lang.IllegalStateException: No Docker Compose file found in directory 'C:\Users\jordi\Desktop\BackEndDev\Spring_Boot_Test\hotelService\.'
at org.springframework.util.Assert.state(Assert.java:97) ~[spring-core-6.1.6.jar:6.1.6]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.getComposeFile(DockerComposeLifecycleManager.java:147) ~[spring-boot-docker-compose-3.2.5.jar:3.2.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.start(DockerComposeLifecycleManager.java:108) ~[spring-boot-docker-compose-3.2.5.jar:3.2.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:53) ~[spring-boot-docker-compose-3.2.5.jar:3.2.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:35) ~[spring-boot-docker-compose-3.2.5.jar:3.2.5]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-6.1.6.jar:6.1.6]
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:98) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplicationRunListeners.lambda$contextLoaded$4(SpringApplicationRunListeners.java:72) ~[spring-boot-3.2.5.jar:3.2.5]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:72) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:432) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.5.jar:3.2.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.5.jar:3.2.5]
at com.practiceDocker.hotelService.HotelServiceApplication.main(HotelServiceApplication.java:15) ~[classes/:na]
Comment From: jordikop
help me pls
Comment From: scottfrederick
@jordikop Unfortunately, you haven't provided enough information for anyone to be able to help. When you run your Spring Boot application with Docker Compose support enabled, there must be a compose file in the application's working directory. If you think that's the case but you're still getting an error, you'll need to provide a sample and the steps you're using to run it so we can see what's going on.
Comment From: Fachher
Hi @jordikop and @scottfrederick. I have the same issue as @jordikop has. The problem is the order of the application listener. org.springframework.boot.docker.compose.lifecycle.DockerComposeListener is executed before org.springframework.boot.env.EnvironmentPostProcessorApplicationListener. All values set in application.yml are not known at this moment. For example the location of the docker-compose files spring.docker.compose.file.
In other word org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties is uninitialized.
As a quickfix you can either set the environment variable SPRING_DOCKER_COMPOSE_FILE=foo/bar/docker-compose.yml or do it as following.
final List<String> arguments = new ArrayList<>(Arrays.asList(args));
arguments.add("--spring.docker.compose.file=docker/docker-compose.yaml, docker/postgres/docker-compose.yaml, docker/oracle/docker-compose.yaml, docker/influxdb-grafana/docker-compose.yaml");
arguments.add("--spring.docker.compose.profiles.active=postgres");
final SpringApplication springApplication = new SpringApplication(YourApplicationName.class);
springApplication.setBeanNameGenerator(new QualifiedBeanNameGenerator());
springApplication.run(arguments.toArray(new String[0]));
Comment From: wilkinsona
@Fachher this issue was about poor diagnostics when the compose file could not be found and it has been closed with a fix for that problem. Configuration being ignored, as I think you have described, is a different problem (that could cause the compose file to not be found). Please open a new issue if you'd like us to investigate.