Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed docker compose directory mounting on windows #224

Merged
merged 1 commit into from
Sep 21, 2016
Merged
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 @@ -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