Hello,
with issues #35383 and #36618 @albilu, @digiron and @yurets1 reported that launching an application including a dependency on spring-boot-docker-compose results in throwing an org.springframework.boot.docker.compose.core.DockerOutputParseException: Failed to parse docker JSON.
In issue #35383 @scottfrederick commented that Spring Boot
(...) will try
docker composefirst, and fall back todocker-composeif the former does not work.
If I am not mistaken, @scottfrederick is referring to the method org.springframework.boot.docker.compose.core.DockerCli$DockerCommands.getDockerComposeCommand, where the command docker compose version --format json (processRunner.run("docker", "compose", "version", "--format", "json")) is followed by a command docker-compose version --format json (processRunner.run("docker-compose", "version", "--format", "json")) in case the first call results in an exception.
The stacktrace hints that the second call is involved in throwing above mentioned exception, with
at org.springframework.boot.docker.compose.core.DockerJson.deserialize(DockerJson.java:79) ~[spring-boot-docker-compose-3.1.2.jar:3.1.2]
at org.springframework.boot.docker.compose.core.DockerJson.deserialize(DockerJson.java:71) ~[spring-boot-docker-compose-3.1.2.jar:3.1.2]
at org.springframework.boot.docker.compose.core.DockerCli$DockerCommands.getDockerComposeCommand(DockerCli.java:164) ~[spring-boot-docker-compose-3.1.2.jar:3.1.2]
and DockerCli.java:164
DockerCliComposeVersionResponse response = DockerJson.deserialize(
processRunner.run("docker-compose", "version", "--format", "json"),
DockerCliComposeVersionResponse.class);
If I interpret the documentation right, the command docker-compose version does not support the option --format json, what may be the reason for the above mentioned exception.
Running docker-compose version --format json results in the following output:
Show version information and quit.
Usage: version [--short]
Options:
--short Shows only Compose's version number.
This reads like help text rather than the result of the actual command, and hints that docker-compose version may be called with the option --short instead .
Running docker-compose version --short results in the output of the version number in the format v.v.v.
Could this help to find a (hopefully) simple solution, or have I misinterpreted or missed something? What do you think?
Thank you very much!
Comment From: wilkinsona
I suspect this is a duplicate of #36618. What version of Docker Compose are you using?
Comment From: pi-jMelange
Hello @wilkinsona,
thank you very much for coming back to this topic!
You are right, I continued the topic described in both #35383 and #36618 (and I am very sorry in case you would have preferred it if I continued directly there).
I may be wrong, but to me it seems that regardless of the version of Docker Compose you are using, the implemented fallback mechanism either would not be performed or would fail, since the commands docker compose version and docker-compose version (as one of three exceptions) differ in more than the dash. So I suggested using docker-compose version --short instead of docker-compose version --format json as part of fallback handling.
Thank you very much!
Comment From: mhalbritter
On my machine, both
docker-compose version --format json
{"version":"2.20.2"}
docker compose version --format json
{"version":"2.20.2"}
work. What version of Docker Compose are you using?
Comment From: mhalbritter
The reason this fallback is in there, is that we want to both support Docker Compose when installed as a docker plugin (docker compose) and docker compose as a standalone (docker-compose).
See this:
- https://docs.docker.com/compose/install/linux/
- https://docs.docker.com/compose/install/standalone/
They both have the JSON support for the version command. I suspect you're using an old version of docker compose which is missing this support.
Comment From: pi-jMelange
Thank you very much for your feedback and the additional input, @mhalbritter!
I think I now understand better the background of the decision made with the implementation of the method org.springframework.boot.docker.compose.core.DockerCli$DockerCommands.getDockerComposeCommand, which makes a lot of sense.
I can confirm your suspicions: both @albilu and @yurets1 reported this behavior with Docker Compose 1.29.2 and I was able to reproduce it with the very same version. While I am aware of Docker's statement regarding their support, I understand that, for reasons I do not know, this is the version Canonical still considers supported with Ubuntu's latest LTS release being part of the standard apt software repository. This means, if someone does not want to add anything other than the standard apt software repository (e.g. to avoid potential dependency conflicts), that would be the version available on the system.
Having seen, that you already have a mechanism in place to find out which command to use, I was hoping that a (hopefully) small change could make this feature available to those using the standard apt software repository as well.
If the standalone version of Docker Compose continues to support the command docker-compose version --short, it seems that switching to this command could support all standalone versions.
Of course I fully understand that you need to make decisions where your efforts are best invested and result in the best quality!
Thank you very much!
Comment From: wilkinsona
Thanks, @pi-jMelange. We do not plan to support Docker Compose 1.x. The burden of testing it and the ongoing maintenance outweighs the benefits as it's now end-of-life and folks should be migrating to 2.x.
Comment From: pi-jMelange
Thank you very much for your feedback, @wilkinsona!
I appreciate your and @mhalbritter's efforts with looking into this topic!
Thank you very much!