Skip to content

Commit 2597da2

Browse files
authored
Resolve strategy to detect the remote docker socket (#7727)
Currently, if `DockerClientFactory.instance().getRemoteDockerUnixSocketPath()` is called without resolving the strategy then the remote docker socket can be invalid, for example, using Docker Desktop for Mac with unchecked `Allow the default Docker socket to be used` option. Fixes #7678
1 parent 39f0219 commit 2597da2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/src/main/java/org/testcontainers/DockerClientFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,15 @@ public TransportConfig getTransportConfig() {
160160

161161
@UnstableAPI
162162
public String getRemoteDockerUnixSocketPath() {
163-
if (this.strategy != null && this.strategy.allowUserOverrides()) {
163+
DockerClientProviderStrategy strategy = getOrInitializeStrategy();
164+
if (strategy.allowUserOverrides()) {
164165
String dockerSocketOverride = System.getenv("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE");
165166
if (!StringUtils.isBlank(dockerSocketOverride)) {
166167
return dockerSocketOverride;
167168
}
168169
}
169-
if (this.strategy != null && this.strategy.getRemoteDockerUnixSocketPath() != null) {
170-
return this.strategy.getRemoteDockerUnixSocketPath();
170+
if (strategy.getRemoteDockerUnixSocketPath() != null) {
171+
return strategy.getRemoteDockerUnixSocketPath();
171172
}
172173

173174
URI dockerHost = getTransportConfig().getDockerHost();

0 commit comments

Comments
 (0)