Skip to content

Commit

Permalink
Resolve strategy to detect the remote docker socket (#7727)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eddumelendez committed Oct 27, 2023
1 parent 39f0219 commit 2597da2
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,15 @@ public TransportConfig getTransportConfig() {

@UnstableAPI
public String getRemoteDockerUnixSocketPath() {
if (this.strategy != null && this.strategy.allowUserOverrides()) {
DockerClientProviderStrategy strategy = getOrInitializeStrategy();
if (strategy.allowUserOverrides()) {
String dockerSocketOverride = System.getenv("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE");
if (!StringUtils.isBlank(dockerSocketOverride)) {
return dockerSocketOverride;
}
}
if (this.strategy != null && this.strategy.getRemoteDockerUnixSocketPath() != null) {
return this.strategy.getRemoteDockerUnixSocketPath();
if (strategy.getRemoteDockerUnixSocketPath() != null) {
return strategy.getRemoteDockerUnixSocketPath();
}

URI dockerHost = getTransportConfig().getDockerHost();
Expand Down

0 comments on commit 2597da2

Please sign in to comment.