diff --git a/core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java b/core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java index 683e9d9fdf5..fa5a6eba983 100644 --- a/core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java +++ b/core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java @@ -143,7 +143,7 @@ public DockerComposeContainer(String identifier, List composeFiles) { this.dockerComposeFiles = new DockerComposeFiles(composeFiles); // Use a unique identifier so that containers created for this compose environment can be identified - this.identifier = identifier; + this.identifier = identifier.toLowerCase(); this.project = randomProjectId(); this.dockerClient = DockerClientFactory.lazyClient(); diff --git a/core/src/test/java/org/testcontainers/junit/DockerComposeV2FormatWithIdentifierTest.java b/core/src/test/java/org/testcontainers/junit/DockerComposeV2FormatWithIdentifierTest.java new file mode 100644 index 00000000000..90c041b53b6 --- /dev/null +++ b/core/src/test/java/org/testcontainers/junit/DockerComposeV2FormatWithIdentifierTest.java @@ -0,0 +1,21 @@ +package org.testcontainers.junit; + +import org.junit.Rule; +import org.testcontainers.containers.DockerComposeContainer; + +import java.io.File; + +public class DockerComposeV2FormatWithIdentifierTest extends BaseDockerComposeTest { + + @Rule + public DockerComposeContainer environment = new DockerComposeContainer( + "TEST", + new File("src/test/resources/v2-compose-test.yml") + ) + .withExposedService("redis_1", REDIS_PORT); + + @Override + protected DockerComposeContainer getEnvironment() { + return this.environment; + } +}