|
2 | 2 |
|
3 | 3 | import com.github.dockerjava.api.DockerClient;
|
4 | 4 | import com.github.dockerjava.api.model.Container;
|
| 5 | +import com.github.dockerjava.core.LocalDirectorySSLConfig; |
| 6 | +import com.github.dockerjava.transport.SSLConfig; |
5 | 7 | import com.google.common.annotations.VisibleForTesting;
|
6 | 8 | import com.google.common.base.Joiner;
|
7 | 9 | import com.google.common.base.Splitter;
|
|
22 | 24 | import org.testcontainers.containers.wait.strategy.Wait;
|
23 | 25 | import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
|
24 | 26 | import org.testcontainers.containers.wait.strategy.WaitStrategy;
|
| 27 | +import org.testcontainers.dockerclient.TransportConfig; |
25 | 28 | import org.testcontainers.lifecycle.Startable;
|
26 | 29 | import org.testcontainers.utility.AuditLogger;
|
27 | 30 | import org.testcontainers.utility.Base58;
|
@@ -605,7 +608,7 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) {
|
605 | 608 | // as the docker daemon, just mapping the docker control socket is OK.
|
606 | 609 | // As there seems to be a problem with mapping to the /var/run directory in certain environments (e.g. CircleCI)
|
607 | 610 | // we map the socket file outside of /var/run, as just /docker.sock
|
608 |
| - addFileSystemBind("/" + DockerClientFactory.instance().getDockerUnixSocketPath(), "/docker.sock", READ_WRITE); |
| 611 | + addFileSystemBind("/" + DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), "/docker.sock", READ_WRITE); |
609 | 612 | addEnv("DOCKER_HOST", "unix:///docker.sock");
|
610 | 613 | setStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy());
|
611 | 614 | setWorkingDirectory(containerPwd);
|
@@ -690,7 +693,17 @@ public void invoke() {
|
690 | 693 |
|
691 | 694 | String dockerHost = System.getenv("DOCKER_HOST");
|
692 | 695 | if (dockerHost == null) {
|
693 |
| - dockerHost = "unix://" + DockerClientFactory.instance().getDockerUnixSocketPath(); |
| 696 | + TransportConfig transportConfig = DockerClientFactory.instance().getTransportConfig(); |
| 697 | + SSLConfig sslConfig = transportConfig.getSslConfig(); |
| 698 | + if (sslConfig != null) { |
| 699 | + if (sslConfig instanceof LocalDirectorySSLConfig) { |
| 700 | + environment.put("DOCKER_CERT_PATH", ((LocalDirectorySSLConfig) sslConfig).getDockerCertPath()); |
| 701 | + environment.put("DOCKER_TLS_VERIFY", "true"); |
| 702 | + } else { |
| 703 | + logger().warn("Couldn't set DOCKER_CERT_PATH. `sslConfig` is present but it's not LocalDirectorySSLConfig."); |
| 704 | + } |
| 705 | + } |
| 706 | + dockerHost = transportConfig.getDockerHost().toString(); |
694 | 707 | }
|
695 | 708 | environment.put("DOCKER_HOST", dockerHost);
|
696 | 709 |
|
|
0 commit comments