I'm getting a NPE because the key in inspected map and the ID of DockerCliComposePsResponse are different, so the value of that Map could not be found.
Screenshots
console when run spring boot
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.5)
2023-10-21T00:05:19.654+09:00 INFO 4906 --- [ main] m.z.ServerApplicationKt : Starting ServerApplicationKt using Java 17.0.9 with PID 4906
2023-10-21T00:05:19.656+09:00 INFO 4906 --- [ main] m.z.ServerApplicationKt : The following 1 profile is active: "local"
2023-10-21T00:05:19.694+09:00 INFO 4906 --- [ main] .s.b.d.c.l.DockerComposeLifecycleManager : Using Docker Compose file 'some/path/compose.yaml'
2023-10-21T00:11:45.208+09:00 ERROR 4906 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.NullPointerException: Cannot invoke "org.springframework.boot.docker.compose.core.DockerCliInspectResponse.hostConfig()" because "inspectResponse" is null
at org.springframework.boot.docker.compose.core.DefaultConnectionPorts.isHostNetworkMode(DefaultConnectionPorts.java:56) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.core.DefaultConnectionPorts.<init>(DefaultConnectionPorts.java:47) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.core.DefaultRunningService.<init>(DefaultRunningService.java:55) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.core.DefaultDockerCompose.getRunningServices(DefaultDockerCompose.java:83) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.start(DockerComposeLifecycleManager.java:120) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:53) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:35) ~[spring-boot-docker-compose-3.1.5.jar:3.1.5]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:174) ~[spring-context-6.0.13.jar:6.0.13]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-6.0.13.jar:6.0.13]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:145) ~[spring-context-6.0.13.jar:6.0.13]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:133) ~[spring-context-6.0.13.jar:6.0.13]
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:98) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplicationRunListeners.lambda$contextLoaded$4(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.5.jar:3.1.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.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:420) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.5.jar:3.1.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.5.jar:3.1.5]
Break point
docker compose version
Without --no-trunc flag
$ docker compose ps --format=json
{...,"ID":"4634e75ac669","Image":"postgres:latest",...}
With --no-trunc flag
$ docker compose ps --format=json --no-trunc
{...,"ID":"4634e75ac66930fbce37ec146669182dabfa2f7b254a5f6afaa34d1cf15dbb65","Image":"postgres:latest",...}
The current docker compose cli version has been updated, and it is expected to be solved by attaching --no-trunc flag.
- updated version: https://github.com/docker/compose/releases/tag/v2.23.0
- related pr: https://github.com/docker/compose/pull/11038
Comment From: osiegmar
GitHub just updated their action runners by also updating to Docker Compose 2.23.0. See https://github.com/actions/runner-images/commit/388d55d0d741619a8718061d401166ebdc1f01f5 and https://github.com/actions/runner-images/commit/ad34bed33ee26de0337eb082dbda0680026d7ac6
All docker compose related spring-boot tasks are currently broken – at least with Ubuntu 20.04 and 22.04.
Unsure who needs to fix that.
Comment From: michelbernardods
My operating system is MacOS m1 and I also have the same problem.
Docker compose up is working and when I start the java application with spring boot it breaks.
2023-11-06T23:11:43.342-03:00 ERROR 20165 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.NullPointerException: Cannot invoke "org.springframework.boot.docker.compose.core.DockerCliInspectResponse.hostConfig()" because "inspectResponse" is null
at org.springframework.boot.docker.compose.core.DefaultConnectionPorts.isHostNetworkMode(DefaultConnectionPorts.java:56) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.core.DefaultConnectionPorts.<init>(DefaultConnectionPorts.java:47) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.core.DefaultRunningService.<init>(DefaultRunningService.java:55) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.core.DefaultDockerCompose.getRunningServices(DefaultDockerCompose.java:88) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager.startup(DockerComposeLifecycleManager.java:118) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:53) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.docker.compose.lifecycle.DockerComposeListener.onApplicationEvent(DockerComposeListener.java:35) ~[spring-boot-docker-compose-3.1.0-RC1.jar:3.1.0-RC1]
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-RC1.jar:3.1.0-RC1]
at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:98) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplicationRunListeners.lambda$contextLoaded$4(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:72) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:415) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[spring-boot-3.1.0-RC1.jar:3.1.0-RC1]
Comment From: michelbernardods
I'm trying to downgrade docker compose to 2.20.3 on mac m1 but I can't, I've tried several ways like:
brew install docker-compose@2.20.4
reinstall docker, but it installs in the latest version which is 2.23.0
Comment From: wilkinsona
@michelbernardods this issue should be fixed in 3.1.6 that will be released later this month. Please try 3.1.6-SNAPSHOT, available from https://repo.spring.io/snapshot.
Comment From: LiveNathan
@michelbernardods this issue should be fixed in 3.1.6 that will be released later this month. Please try 3.1.6-SNAPSHOT, available from https://repo.spring.io/snapshot.
Unfortunately, this doesn't work for me because 3.1.6 changes some way that enums are handled. Is there another solution?
Comment From: wilkinsona
@LiveNathan The only other known solution is to downgrade Docker Compose to a version before the breaking change.
3.1.6 changes some way that enums are handled
Can you share some more information about this please? We're not aware of any changes to enum handling.
Comment From: LiveNathan
Ah, ok. I could be wrong. I was attempting to get docker compose to work today. I was getting the "inspectResponse" is null' error that lead me to this thread. I upgraded to spring boot 3.1.6. Docker compose started working again, but Hibernate could not find any of my enums in the database. If I export the DDL and run it manually from the console, it works fine, but if I try to have Hibernate run it itself, it won't generate any off the tables that references enums. I did a quick search for "did spring boot v3.1.6 change the way it handles enums with jpa?" and got this:
Comment From: wilkinsona
It's possible that Hibernate has changed how it handles enums but Spring Boot itself has not done so. At the time of writing, Spring Boot 3.1.6 snapshots use the same version of Hibernate as 3.1.5 which is 6.2.13.Final. I can't say much more than that without knowing from which version you have upgraded.
This is quite a long way off topic for this issue so please follow up on Stack Overflow if you have any further questions.
Comment From: LiveNathan
Ok, thanks wilkinsona. I probably won't post it on StackOverflow. I haven't found much help there recently. I'll just downgrade spring boot and go without docker compose.
Comment From: SamBenningECG
I just encountered this error after upgrading Docker Desktop on Windows to v4.25.1.
Reverted to v4.24.2 and its working.
Comment From: philwebb
@SamBenningECG Did you try the SNAPSHOT of Spring Boot 3.1.6?
Comment From: DaddyMoe
Hey @philwebb / @wilkinsona
I am getting Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:3.1.6-SNAPSHOT when I try pointing to the 3.1.6-SNAPSHOT/
Here is snippet from my pom.xml for this:
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.6-SNAPSHOT</version>
<relativePath />
</parent>
...
<repositories>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
...
Error:
╰─⠠⠵ mvn clean install
[INFO] Scanning for projects...
Downloading from spring-snapshot: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/3.1.6-SNAPSHOT/maven-metadata.xml
Downloaded from spring-snapshot: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/3.1.6-SNAPSHOT/maven-metadata.xml (807 B at 1.2 kB/s)
Downloading from spring-snapshot: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/3.1.6-SNAPSHOT/spring-boot-starter-parent-3.1.6-20231121.172545-80.pom
Downloaded from spring-snapshot: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/3.1.6-SNAPSHOT/spring-boot-starter-parent-3.1.6-20231121.172545-80.pom (13 kB at 65 kB/s)
[INFO]
[INFO] ------------------------< com.jimbo:api >------------------------
[INFO] Building api 0.0.1-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.springframework.boot:spring-boot-maven-plugin:jar:3.1.6-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.642 s
[INFO] Finished at: 2023-11-21T22:13:29Z
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.springframework.boot:spring-boot-maven-plugin:3.1.6-SNAPSHOT or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.springframework.boot:spring-boot-maven-plugin:jar:3.1.6-SNAPSHOT (absent): Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:3.1.6-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Comment From: scottfrederick
@DaddyMoe You need to configure pluginRepositories to find snapshot versions of the Spring Boot Maven plugin. Snapshots frequently depend on milestone releases of other Spring dependencies, so the full configuration should look like this:
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
Comment From: harasees-singh
I encountered this error after upgrading to a newer version of Docker Desktop on macos. An older version like v4.22.0 is working fine for me.
Comment From: scottfrederick
@harasees-singh What version of Spring Boot are you using? Can you try 3.1.6-SNAPSHOT and see if that works with the newer versions of Docker Desktop with Compose?
Comment From: harasees-singh
@scottfrederick I am using Spring Boot version 3.1.0. I am unable to try 3.1.6-SNAPSHOT at the moment due to some complications.
Comment From: atefbkl
I had the same problem but resolved with this config : spring-boot version 3.1.1 & docker-compose version 3.1.6