Skip to content
Open
Show file tree
Hide file tree
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 @@ -70,6 +70,11 @@ public TransportConfig getTransportConfig() {
.build();
}

@Override
public String getRemoteDockerUnixSocketPath() {
return getSetting("docker.socket.override").orElse(null);
}

@Override
protected int getPriority() {
return PRIORITY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,39 @@ public void testWhenDockerHostPresent() {
assertThat(transportConfig.getSslConfig()).isEqualTo(defaultSSLConfig);
}

@Test
public void testWhenDockerSocketPresent() {
Mockito
.doReturn("auto")
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrProperty(eq("dockerconfig.source"), anyString());
Mockito
.doReturn(null)
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrUserProperty(eq("docker.host"), isNull());
Mockito
.doReturn(null)
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrUserProperty(eq("docker.tls.verify"), isNull());
Mockito
.doReturn(null)
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrUserProperty(eq("docker.cert.path"), isNull());
Mockito
.doReturn("/var/run/docker-alt.sock")
.when(TestcontainersConfiguration.getInstance())
.getEnvVarOrUserProperty(eq("docker.socket.override"), isNull());

EnvironmentAndSystemPropertyClientProviderStrategy strategy = new EnvironmentAndSystemPropertyClientProviderStrategy();

TransportConfig transportConfig = strategy.getTransportConfig();
assertThat(transportConfig.getDockerHost().toString()).isEqualTo(defaultDockerHost);
assertThat(transportConfig.getSslConfig()).isEqualTo(defaultSSLConfig);

String remoteDockerUnixSocketPath = strategy.getRemoteDockerUnixSocketPath();
assertThat(remoteDockerUnixSocketPath).isEqualTo("/var/run/docker-alt.sock");
}

@Test
public void testWhenDockerHostAndSSLConfigPresent() throws IOException {
Path tempDir = Files.createTempDirectory("testcontainers-test");
Expand Down
7 changes: 4 additions & 3 deletions docs/features/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ illustrates usage:

```properties
docker.client.strategy=org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy
docker.host=tcp\://my.docker.host\:1234 # Equivalent to the DOCKER_HOST environment variable. Colons should be escaped.
docker.tls.verify=1 # Equivalent to the DOCKER_TLS_VERIFY environment variable
docker.cert.path=/some/path # Equivalent to the DOCKER_CERT_PATH environment variable
docker.host=tcp\://my.docker.host\:1234 # Equivalent to the DOCKER_HOST environment variable. Colons should be escaped.
docker.socket.override=/var/run/docker-alt.sock # Equivalent to the TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE environment variable.
docker.tls.verify=1 # Equivalent to the DOCKER_TLS_VERIFY environment variable
docker.cert.path=/some/path # Equivalent to the DOCKER_CERT_PATH environment variable
```
In addition, you can deactivate this behaviour by specifying:
```properties
Expand Down