[Bug]: DockerDesktopClientProviderStrategy is always applicable
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- docker, java
- Domain
- testing-qa
Research direction
Inspect DockerDesktopClientProviderStrategy, focusing on socketPath, isApplicable(), and getTransportConfig(). Start by reproducing the strategy selection on macOS without Docker Desktop, then review nearby tests or the strategy test suite. Done means the strategy is not selected when its socket is unavailable and no NullPointerException occurs while configurations are attempted.
Written by the indexing model from the issue text.
Description
Module
Core
Testcontainers version
2.0.5
Using the latest Testcontainers version?
Yes
Host OS
macOS
Host Arch
ARM
Docker version
29.5.3
What happened?
DockerDesktopClientProviderStrategy is always applicable even when Docker Desktop is not installed at all. It happens because the socketPath field is annotated with @Getter(lazy = true) and so its actual type is AtomicReference, but the isApplicable() method checks nullability as this.socketPath != null.
@Getter(lazy = true)
@Nullable
private final Path socketPath = resolveSocketPath();
@Override
protected boolean isApplicable() {
return (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC) && this.socketPath != null;
}
Finally, the getTransportConfig() method fails with NPE as getSocketPath() returns null.
@Override
public TransportConfig getTransportConfig() throws InvalidConfigurationException {
return TransportConfig.builder().dockerHost(URI.create("unix://" + getSocketPath().toString())).build();
}
Relevant log output
[Test worker] ERROR o.t.d.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock)
DockerDesktopClientProviderStrategy: failed with exception NullPointerException (Cannot invoke "java.nio.file.Path.toString()" because the return value of "org.testcontainers.dockerclient.DockerDesktopClientProviderStrategy.getSocketPath()" is null)
Additional Information
No response
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testcontainers/testcontainers-java
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-java#11997 · 1 comment ·
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching Opentype/enhancement
Difficulty 1/5 Under an hour Newbie friendliness 85/100
testcontainers/testcontainers-java#11967 ·
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-java#11941 ·
-
type/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
testcontainers/testcontainers-java#11578 ·
-
help wanted type/feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
testcontainers/testcontainers-java#8657 · 4 comments ·
All issues in testcontainers/testcontainers-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100