Skip to content

Commit

Permalink
Fix bind mounts for ResourceReaper/ryuk and ContainerisedDockerCompose
Browse files Browse the repository at this point in the history
Relates to #545
Relates to testcontainers#2998
  • Loading branch information
gesellix committed Aug 26, 2020
1 parent 6bdbc8f commit 8e94b84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.testcontainers.dockerclient.DockerClientProviderStrategy;
import org.testcontainers.dockerclient.DockerMachineClientProviderStrategy;
import org.testcontainers.dockerclient.TransportConfig;
Expand Down Expand Up @@ -145,9 +146,12 @@ public String getRemoteDockerUnixSocketPath() {
}

URI dockerHost = getTransportConfig().getDockerHost();
return "unix".equals(dockerHost.getScheme())
String path = "unix".equals(dockerHost.getScheme())
? dockerHost.getRawPath()
: "/var/run/docker.sock";
return SystemUtils.IS_OS_WINDOWS
? "/" + path
: path;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) {
// 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("/" + DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), "/docker.sock", READ_WRITE);
addFileSystemBind(DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), "/docker.sock", READ_WRITE);
addEnv("DOCKER_HOST", "unix:///docker.sock");
setStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy());
setWorkingDirectory(containerPwd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static String start(String hostIpAddress, DockerClient client) {
DockerClientFactory.instance().checkAndPullImage(client, ryukImage);

List<Bind> binds = new ArrayList<>();
binds.add(new Bind("/" + DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), new Volume("/var/run/docker.sock")));
binds.add(new Bind(DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), new Volume("/var/run/docker.sock")));

String ryukContainerId = client.createContainerCmd(ryukImage)
.withHostConfig(new HostConfig().withAutoRemove(true))
Expand Down

0 comments on commit 8e94b84

Please sign in to comment.