Skip to content

Commit 6442d27

Browse files
authored
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
1 parent 1a61543 commit 6442d27

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public DockerComposeContainer(String identifier, List<File> composeFiles) {
143143
this.dockerComposeFiles = new DockerComposeFiles(composeFiles);
144144

145145
// Use a unique identifier so that containers created for this compose environment can be identified
146-
this.identifier = identifier;
146+
this.identifier = identifier.toLowerCase();
147147
this.project = randomProjectId();
148148

149149
this.dockerClient = DockerClientFactory.lazyClient();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.testcontainers.junit;
2+
3+
import org.junit.Rule;
4+
import org.testcontainers.containers.DockerComposeContainer;
5+
6+
import java.io.File;
7+
8+
public class DockerComposeV2FormatWithIdentifierTest extends BaseDockerComposeTest {
9+
10+
@Rule
11+
public DockerComposeContainer environment = new DockerComposeContainer(
12+
"TEST",
13+
new File("src/test/resources/v2-compose-test.yml")
14+
)
15+
.withExposedService("redis_1", REDIS_PORT);
16+
17+
@Override
18+
protected DockerComposeContainer getEnvironment() {
19+
return this.environment;
20+
}
21+
}

0 commit comments

Comments
 (0)