Code Review Videos > How I Fixed > Spring Boot + Docker Compose – unknown flag: –orphans

Spring Boot + Docker Compose – unknown flag: –orphans

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: --orphansCode 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.0docker -v
Docker version 24.0.7, build afdd53bCode 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:

And here’s what I ended up with after:

docker -v                                                                                                                        
Docker version 27.4.1, build b9d17eadocker compose version                                                                                                           
Docker Compose version v2.32.1Code 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=falseCode 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 # etcCode language: PHP (php)

    That works, but I guess there is not point have the Spring integration at that point.

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.