From 6442d27bda2389c8615e24c65aadf9c3f292c247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez=20Gonzales?= Date: Fri, 28 Apr 2023 18:41:31 -0600 Subject: [PATCH] Lowercase identifier in DockerComposeContainer (#6944) According to the [docs](https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name), `COMPOSE_PROJECT_NAME` must be lowescase. Fixes #6943 --- .../containers/DockerComposeContainer.java | 2 +- ...ckerComposeV2FormatWithIdentifierTest.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 core/src/test/java/org/testcontainers/junit/DockerComposeV2FormatWithIdentifierTest.java 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; + } +}