This is a pretty straightforward one. However as someone very much still learning about Spring Boot, this one threw me. A few days ago I added the spring-boot-docker-compose
dependency to an existing Spring Boot project of mine, and when I tried to bring up the application I got the following error:
org.springframework.boot.docker.compose.core.ProcessExitException: 'docker compose --file /home/chris/Development/my-project/compose.yaml --ansi never ps --orphans=false --format=json' failed with exit code 16.
Stdout:
Stderr:
unknown flag: --orphans
Code language: JavaScript (javascript)
I hacked about a little with this, but as I was in the middle of another task, I didn’t come up with a resolution. I was left thinking it was something I had misunderstood with regards to adding a new dependency to my existing project.
However, this morning I created a new Spring Boot project including the Docker Compose support via Start Spring IO.
And I got the exact same error.
So I knew it wasn’t my other project – but rather something common between the two projects. AKA, my machine.
The Fix
The fix is pretty simple.
You need to update your local version of Docker.
In my case:
➜ docker compose version
Docker Compose version v2.21.0
➜ docker -v
Docker version 24.0.7, build afdd53b
Code language: CSS (css)
Turns out, that’s pretty old on both fronts.
You don’t need to know the latest version number to upgrade, just follow the documentation.
Here’s some useful links:
- The latest Docker release notes
- The latest Docker Compose release notes
- Docker installation instructions (also includes upgrading)
And here’s what I ended up with after:
➜ docker -v
Docker version 27.4.1, build b9d17ea
➜ docker compose version
Docker Compose version v2.32.1
Code language: CSS (css)
Once this was done, my Spring Boot app started just fine.
A Workaround
If you don’t want to, or can’t upgrade your local Docker version, the workaround I used was as follows.
Firstly, make a change in the application.properties
file:
spring.docker.compose.enabled=false
Code language: JavaScript (javascript)
Then start your docker compose setup from the command line (or via the GUI if that’s what you prefer).
docker compose up # etc
Code language: PHP (php)
That works, but I guess there is not point have the Spring integration at that point.