Skip to content

Commit

Permalink
add check for compatible Docker OS type (#1780)
Browse files Browse the repository at this point in the history
* add container OSType check for Windows strategies

as Windows containers are not supported at the moment

* fix typo

* generic check for OS Type, as we currently only support Linux containers

* use debug logging when checking OS type

* words
  • Loading branch information
jetersen authored and rnorth committed Aug 25, 2019
1 parent 79adf4e commit 8894dae
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -5,6 +5,7 @@
import com.github.dockerjava.core.DockerClientConfig;
import com.google.common.base.Throwables;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.Nullable;
import org.rnorth.ducttape.TimeoutException;
import org.rnorth.ducttape.ratelimits.RateLimiter;
Expand Down Expand Up @@ -111,6 +112,7 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie
try {
strategy.test();
LOGGER.info("Found Docker environment with {}", strategy.getDescription());
strategy.checkOSType();

if (strategy.isPersistable()) {
TestcontainersConfiguration.getInstance().updateGlobalConfig("docker.client.strategy", strategy.getClass().getName());
Expand Down Expand Up @@ -199,4 +201,15 @@ protected void ping(DockerClient client, int timeoutInSeconds) {
public String getDockerHostIpAddress() {
return DockerClientConfigUtils.getDockerHostIpAddress(this.config);
}

protected void checkOSType() {
LOGGER.debug("Checking Docker OS type for {}", this.getDescription());
String osType = client.infoCmd().exec().getOsType();
if (StringUtils.isBlank(osType)) {
LOGGER.warn("Could not determine Docker OS type");
} else if (!osType.equals("linux")) {
LOGGER.warn("{} is currently not supported", osType);
throw new InvalidConfigurationException(osType + " containers are currently not supported");
}
}
}

0 comments on commit 8894dae

Please sign in to comment.