Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ protected Object constructObject(Node node) {

private void parseAndValidate() {
final Map<String, ?> servicesMap;
if (composeFileContent.containsKey("version")) {
if ("2.0".equals(composeFileContent.get("version"))) {
log.warn(
"Testcontainers may not be able to clean up networks spawned using Docker Compose v2.0 files. " +
"Please see https://github.com/testcontainers/moby-ryuk/issues/2, and specify 'version: \"2.1\"' or " +
"higher in {}",
composeFileName
);
}
if (composeFileContent.containsKey("version") && "2.0".equals(composeFileContent.get("version"))) {
log.warn(
"Testcontainers may not be able to clean up networks spawned using Docker Compose v2.0 files. " +
"Please see https://github.com/testcontainers/moby-ryuk/issues/2, and specify 'version: \"2.1\"' or " +
"higher in {}",
composeFileName
);
}

if (composeFileContent.containsKey("services")) {
final Object servicesElement = composeFileContent.get("services");
if (servicesElement == null) {
log.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ public void shouldObtainImageNamesV2() {
);
}

@Test
public void shouldObtainImageNamesV2WithNoVersionTag() {
File file = new File("src/test/resources/docker-compose-imagename-parsing-v2-no-version.yml");
ParsedDockerComposeFile parsedFile = new ParsedDockerComposeFile(file);
assertThat(parsedFile.getServiceNameToImageNames())
.as("all defined images are found")
.contains(
entry("mysql", Sets.newHashSet("mysql")),
entry("redis", Sets.newHashSet("redis")),
entry("custom", Sets.newHashSet("postgres"))
);
}

@Test
public void shouldObtainImageFromDockerfileBuild() {
File file = new File("src/test/resources/docker-compose-imagename-parsing-dockerfile.yml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
redis:
image: redis
mysql:
image: mysql
custom:
build: .
networks:
custom_network: {}