diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index 6f0c744cedf..f7bf47e506e 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -93,6 +93,8 @@ static Map markerLabels() { private String activeApiVersion; + private boolean runningWindowsContainers; + @Getter(lazy = true) private final boolean fileMountingSupported = checkMountableFile(); @@ -210,6 +212,8 @@ public void close() { Version version = client.versionCmd().exec(); log.debug("Docker version: {}", version.getRawValues()); activeApiVersion = version.getApiVersion(); + String osType = dockerInfo.getOsType(); + runningWindowsContainers = StringUtils.isNotBlank(osType) && osType.equals("windows"); log.info( "Connected to docker: \n" + " Server Version: " + @@ -219,7 +223,7 @@ public void close() { activeApiVersion + "\n" + " Operating System: " + - dockerInfo.getOperatingSystem() + + dockerInfo.getOperatingSystem() + (runningWindowsContainers ? " (WCOW)" : "") + "\n" + " Total Memory: " + dockerInfo.getMemTotal() / @@ -370,6 +374,14 @@ public String getActiveApiVersion() { return activeApiVersion; } + /** + * @return whether the daemon is running Windows containers + */ + public boolean isRunningWindowsContainers() { + client(); + return runningWindowsContainers; + } + /** * @return the docker execution driver of the daemon that we have connected to */ diff --git a/core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java b/core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java index 557e8ba6cdf..99057e527d6 100644 --- a/core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java +++ b/core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java @@ -104,8 +104,8 @@ public boolean allowUserOverrides() { } /** - /* @return the path under which the Docker unix socket is reachable relative to the Docker daemon - */ + * @return the path under which the Docker unix socket is reachable relative to the Docker daemon + */ public String getRemoteDockerUnixSocketPath() { return null; } @@ -301,7 +301,7 @@ private static boolean tryOutStrategy(List configurationFailures, Docker String osType = strategy.getInfo().getOsType(); if (StringUtils.isBlank(osType)) { log.warn("Could not determine Docker OS type"); - } else if (!osType.equals("linux")) { + } else if (!osType.equals("linux") && !osType.equals("windows")) { log.warn("{} is currently not supported", osType); throw new InvalidConfigurationException(osType + " containers are currently not supported"); } diff --git a/core/src/main/java/org/testcontainers/utility/RyukContainer.java b/core/src/main/java/org/testcontainers/utility/RyukContainer.java index 01c68f4b8a3..9fda47b15c1 100644 --- a/core/src/main/java/org/testcontainers/utility/RyukContainer.java +++ b/core/src/main/java/org/testcontainers/utility/RyukContainer.java @@ -8,8 +8,8 @@ class RyukContainer extends GenericContainer { - RyukContainer() { - super("testcontainers/ryuk:0.6.0"); + RyukContainer(boolean runningWindowsContainers) { + super("testcontainers/ryuk:0.7.0"); withExposedPorts(8080); withCreateContainerCmdModifier(cmd -> { cmd.withName("testcontainers-ryuk-" + DockerClientFactory.SESSION_ID); @@ -17,9 +17,15 @@ class RyukContainer extends GenericContainer { cmd .getHostConfig() .withAutoRemove(true) - .withPrivileged(TestcontainersConfiguration.getInstance().isRyukPrivileged()) + .withPrivileged(TestcontainersConfiguration.getInstance().isRyukPrivileged() + && !runningWindowsContainers) .withBinds( - new Bind( + runningWindowsContainers + ? new Bind( + "//./pipe/docker_engine", + new Volume("//./pipe/docker_engine") + ) + : new Bind( DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), new Volume("/var/run/docker.sock") ) diff --git a/core/src/main/java/org/testcontainers/utility/RyukResourceReaper.java b/core/src/main/java/org/testcontainers/utility/RyukResourceReaper.java index 7e1b7802fb0..52949d6b8ba 100644 --- a/core/src/main/java/org/testcontainers/utility/RyukResourceReaper.java +++ b/core/src/main/java/org/testcontainers/utility/RyukResourceReaper.java @@ -33,7 +33,7 @@ class RyukResourceReaper extends ResourceReaper { private final AtomicBoolean started = new AtomicBoolean(false); - private final RyukContainer ryukContainer = new RyukContainer(); + private final RyukContainer ryukContainer = new RyukContainer(DockerClientFactory.instance().isRunningWindowsContainers()); @Override public void init() {