Docker version: 26.1.3
Docker Compose version: v2.20.2
The shouldWorkWithProfiles
method test fails with the following log:
java.lang.AssertionError: Did not expect service 'redis2', but found it in [[junit-15645479379355523684-redis1-1, junit-15645479379355523684-redis2-1, junit-15645479379355523684-redis3-1]]
at org.springframework.boot.docker.compose.core.DefaultDockerComposeIntegrationTests.assertThatDoesNotContainService(DefaultDockerComposeIntegrationTests.java:104)
at org.springframework.boot.docker.compose.core.DefaultDockerComposeIntegrationTests.shouldWorkWithProfiles(DefaultDockerComposeIntegrationTests.java:71)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Comment From: wilkinsona
@LinkDownZ, have you modified DefaultDockerComposeIntegrationTests
? The line numbers in the stack trace do not match the latest (3911507b3611f4f12c66052a76a3fe03cab9417e) code on 3.4.x
:
Line 71 is blank:
https://github.com/spring-projects/spring-boot/blob/3911507b3611f4f12c66052a76a3fe03cab9417e/spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/core/DefaultDockerComposeIntegrationTests.java#L71
And line 104 is a closing brace:
https://github.com/spring-projects/spring-boot/blob/3911507b3611f4f12c66052a76a3fe03cab9417e/spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/core/DefaultDockerComposeIntegrationTests.java#L104
Comment From: LinkDownZ
I saved the profiles.yaml.
Sorry, the error log should be:
java.lang.AssertionError: Did not expect service 'redis2', but found it in [[junit-16685237477844384657-redis1-1, junit-16685237477844384657-redis2-1, junit-16685237477844384657-redis3-1]]
at org.springframework.boot.docker.compose.core.DefaultDockerComposeIntegrationTests.assertThatDoesNotContainService(DefaultDockerComposeIntegrationTests.java:102)
at org.springframework.boot.docker.compose.core.DefaultDockerComposeIntegrationTests.shouldWorkWithProfiles(DefaultDockerComposeIntegrationTests.java:69)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Comment From: wilkinsona
Can you please debug the test and verify that the expected --profile
arguments are being included in the docker compose ps
commands that the test runs? The command's created in org.springframework.boot.docker.compose.core.DockerCli.createCommand(Type)
. If the expected arguments are there, it would also be interesting to know how things behave if you run the same command directly on the command line.
Comment From: LinkDownZ
docker compose --file /tmp/junit-16008333915686240144/profiles.yaml --ansi never --profile 1 ps --format=json`
`[{"ID":"5242dd62e5e24f7f813441ac695b283abf34c56ca443485b63d10d9a56bb78e8","Name":"root-redis1-1","Image":"redis:7.0.11","Command":"docker-entrypoint.sh redis-server","Project":"root","Service":"redis1","Created":1750195118,"State":"running","Status":"Up 6 minutes","Health":"","ExitCode":0,"Publishers":[{"URL":"0.0.0.0","TargetPort":6379,"PublishedPort":46399,"Protocol":"tcp"},{"URL":"::","TargetPort":6379,"PublishedPort":46352,"Protocol":"tcp"}]},{"ID":"4b480eecf7c5f03d1f7db8efcce138079eda7fb503649470dc10ef20aad0f617","Name":"root-redis2-1","Image":"redis:7.0.11","Command":"docker-entrypoint.sh redis-server","Project":"root","Service":"redis2","Created":1750195118,"State":"running","Status":"Up 6 minutes","Health":"","ExitCode":0,"Publishers":[{"URL":"0.0.0.0","TargetPort":6379,"PublishedPort":46400,"Protocol":"tcp"},{"URL":"::","TargetPort":6379,"PublishedPort":46353,"Protocol":"tcp"}]},{"ID":"52715b612c0e9d433146c690967154818bbe9b4837f3e1d707c372e6959e2500","Name":"root-redis3-1","Image":"redis:7.0.11","Command":"docker-entrypoint.sh redis-server","Project":"root","Service":"redis3","Created":1750195118,"State":"running","Status":"Up 6 minutes","Health":"","ExitCode":0,"Publishers":[{"URL":"0.0.0.0","TargetPort":6379,"PublishedPort":46398,"Protocol":"tcp"},{"URL":"::","TargetPort":6379,"PublishedPort":46351,"Protocol":"tcp"}]}]
I'm not sure whether this is correct.
Comment From: wilkinsona
It looks like --profile
is being ignored as it's returned all 3 services.
Docker Compose version: v2.20.2
This is quite an older version of Docker Compose (it was released in mid-2023). Can you please upgrade and try again?
Comment From: LinkDownZ
Upgrading to Docker Compose version v2.24.4
allowed the build to succeed.