testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Add support for `--profiles` to `DockerComposeContainer`

Open jstanik opened this issue 3 years ago • 2 comments

When starting DockerComposeContainer (local) with option --profile then this option is not used when down is executed at the end of the test. As a result it does not stop container that was started as a result of using a profile. The down then fails with the error:

org.testcontainers.containers.ContainerLaunchException: Local Docker Compose exited abnormally with code 1 whilst running command: down -v
	at org.testcontainers.containers.LocalDockerCompose.invoke(DockerComposeContainer.java:773)
	at org.testcontainers.containers.DockerComposeContainer.runWithCompose(DockerComposeContainer.java:309)

In my case the true error is probably:

failed to remove network 919...72e: Error response from daemon: error while removing network: network docker-compose_default id 919...72e has active endpoints

jstanik avatar Feb 11 '22 12:02 jstanik

Does the java implementation of test containers support docker-compose profiles? (from the api it isn't obvious). I noticed that the node impl supports profiles though.

https://github.com/testcontainers/testcontainers-node/releases/tag/v7.23.0

bjconlan avatar Jul 05 '22 06:07 bjconlan

Testcontainers' DockerComposeContainer implementation currently does not support --profiles explicitly. As @jstanik observed, you can run the container with certain options withOptions("--profiles foo"), but as it is the case with the down command, it might not work as expected.

kiview avatar Jul 05 '22 06:07 kiview