Skip to content

Commit

Permalink
Merge pull request #224 from scetix/master
Browse files Browse the repository at this point in the history
Fixed docker compose directory mounting on windows
  • Loading branch information
rnorth committed Sep 21, 2016
2 parents acea6a9 + c01b13c commit 75a744c
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.lang.SystemUtils;
import org.junit.runner.Description;
import org.rnorth.ducttape.ratelimits.RateLimiter;
import org.rnorth.ducttape.ratelimits.RateLimiterBuilder;
Expand All @@ -17,6 +18,7 @@
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.startupcheck.IndefiniteWaitOneShotStartupCheckStrategy;
import org.testcontainers.utility.Base58;
import org.testcontainers.utility.PathUtils;
import org.testcontainers.utility.ResourceReaper;

import java.io.File;
Expand Down Expand Up @@ -286,16 +288,22 @@ public DockerCompose(File composeFile, String identifier) {
addEnv("COMPOSE_PROJECT_NAME", identifier);
// Map the docker compose file into the container
String pwd = composeFile.getAbsoluteFile().getParentFile().getAbsolutePath();
addEnv("COMPOSE_FILE", pwd + "/" + composeFile.getAbsoluteFile().getName());
addFileSystemBind(pwd, pwd, READ_ONLY);
String containerPwd = pwd;

if (SystemUtils.IS_OS_WINDOWS) {
containerPwd = PathUtils.createMinGWPath(containerPwd).substring(1);
}

addEnv("COMPOSE_FILE", containerPwd + "/" + composeFile.getAbsoluteFile().getName());
addFileSystemBind(pwd, containerPwd, READ_ONLY);
// Ensure that compose can access docker. Since the container is assumed to be running on the same machine
// as the docker daemon, just mapping the docker control socket is OK.
// As there seems to be a problem with mapping to the /var/run directory in certain environments (e.g. CircleCI)
// we map the socket file outside of /var/run, as just /docker.sock
addFileSystemBind("/var/run/docker.sock", "/docker.sock", READ_WRITE);
addEnv("DOCKER_HOST", "unix:///docker.sock");
setStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy());
setWorkingDirectory(pwd);
setWorkingDirectory(containerPwd);
}

@Override
Expand Down

0 comments on commit 75a744c

Please sign in to comment.