Skip to content

[Windows 10] Can't find local docker-compose  #460

@bsnisar

Description

@bsnisar

GIVEN: Win 10 machine
<dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers</artifactId> <version>1.4.2</version> <scope>test</scope> </dependency>

WHEN: Start docker compose in a test

@ClassRule
public static DockerComposeContainer dockerCompose = new DockerComposeContainer(ID, COMPOSE_FILE)
        .withLocalCompose(true)
        .withPull(false)
        .withTailChildContainers(true)
        .withExposedService("elastic", 9200)
        .withExposedService("logstash", 9600)
        .withExposedService("stats", 8282);

`

THEN:
org.testcontainers.containers.ContainerLaunchException: Local Docker Compose not found. Is docker-compose on the PATH? at org.testcontainers.containers.LocalDockerCompose.invoke(DockerComposeContainer.java:497) at org.testcontainers.containers.DockerComposeContainer.runWithCompose(DockerComposeContainer.java:151) at org.testcontainers.containers.DockerComposeContainer.createServices(DockerComposeContainer.java:127) at org.testcontainers.containers.DockerComposeContainer.starting(DockerComposeContainer.java:111)

This heppend because of (DockerComposeContainer, line 498): CommandLine.executableExists(COMPOSE_EXECUTABLE)

public static boolean executableExists(String executable) {

    // First check if we've been given the full path already
    File directFile = new File(executable);
    if (directFile.exists() && directFile.canExecute()) {
        return true;
    }

    for (String pathString : getSystemPath()) {
        Path path = Paths.get(pathString);
        if (Files.exists(path.resolve(executable)) && Files.isExecutable(path.resolve(executable))) {
            return true;
        }
    }

    return false;
}

File like docker-compose can't be resolved in PATH, because of there is docker-compose.exe binary on Win10, not simple docker-compose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions