Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App startup fails with confusing message when a Docker Compose file is not found #35383

Closed
scottfrederick opened this issue May 10, 2023 · 13 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@scottfrederick
Copy link
Contributor

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


@scottfrederick scottfrederick added the type: bug A general bug label May 10, 2023
@scottfrederick scottfrederick self-assigned this May 10, 2023
@scottfrederick scottfrederick added this to the 3.1.0 milestone May 10, 2023
@Nick-Wunderdog
Copy link

Also SB 3.1 is using the obsolete "docker-compose", not the new "docker compose".

@scottfrederick
Copy link
Contributor Author

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.

@zt1115798334
Copy link

你们是怎么解决的,我也遇到这个问题了

@digiron
Copy link

digiron commented Jul 5, 2023

For me, its throwing a org.springframework.boot.docker.compose.core.DockerOutputParseException: Failed to parse docker JSON:

@wilkinsona
Copy link
Member

Which versions of Docker and Docker Compose are you using, @digiron?

@yurets1
Copy link

yurets1 commented Jul 10, 2023

Какие версии 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

@yurets1
Copy link

yurets1 commented Jul 10, 2023

Для меня это создает org.springframework.boot.docker.compose.core.DockerOutputParseException: Failed to parse docker JSON:

did you solve this problem?

@wilkinsona
Copy link
Member

wilkinsona commented Jul 10, 2023

@yurets1 You should upgrade to Docker Compose v2. v1 is no longer receiving updates.

@yurets1
Copy link

yurets1 commented Jul 10, 2023

@yurets1 Вы могли бы перейти на Docker Compose v2. версия v1 больше не получает обновлений.

unfortunately same error(

@wilkinsona
Copy link
Member

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.

@jordikop
Copy link

jordikop commented May 6, 2024

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]

@jordikop
Copy link

jordikop commented May 6, 2024

help me pls

@scottfrederick
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

7 participants