Honor checks.disable in Docker detection test#11768
Open
shaches wants to merge 1 commit intotestcontainers:mainfrom
Open
Honor checks.disable in Docker detection test#11768shaches wants to merge 1 commit intotestcontainers:mainfrom
shaches wants to merge 1 commit intotestcontainers:mainfrom
Conversation
When checks.disable is set to true, skip the socket connectivity test in DockerClientProviderStrategy.test(). This allows Windows/WSL2 users with working Docker to bypass the failing socket test while still enabling Docker detection. Fixes testcontainers#4958 - TestContainers cannot detect Docker on Windows/WSL2 despite Docker being accessible via CLI and TCP. The socket connectivity test fails on Windows/WSL2 even when Docker is accessible via curl and CLI. By honoring the existing checks.disable configuration, users can opt out of the connectivity test and rely on their explicit docker.host configuration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TestContainers cannot detect Docker on Windows/WSL2 despite Docker being accessible via CLI and TCP. This is a known issue (#4958, open 3+ years).
The socket connectivity test in \DockerClientProviderStrategy.test()\ fails on Windows/WSL2 even when:
Root Cause
The \ est()\ method creates a Java \Socket\ and attempts to connect to the Docker host. On Windows/WSL2, this socket connection times out or fails despite curl working, likely due to differences in how Java's socket implementation handles localhost resolution vs curl.
Solution
Honor the existing \checks.disable\ configuration in the \ est()\ method. When \checks.disable=true, skip the socket connectivity test and return \ rue\ immediately.
This allows users who have manually verified Docker is working to bypass the failing socket test while still enabling Docker detection.
Changes
Testing
Tested on Windows/WSL2 with:
\
checks.disable=true
docker.host=tcp://localhost:2375
docker.client.strategy=org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy
\\
Integration tests now pass successfully with MySQL container starting in ~52 seconds.
Backwards Compatibility
Notes
This fix was discovered and implemented by the SWE-1.6 AI model during pair programming. After extensive investigation of the TestContainers source code to understand why Docker detection was failing on Windows/WSL2 despite Docker being accessible, the solution was found by leveraging the existing \checks.disable\ configuration option to provide an escape hatch for environments where the socket connectivity test doesn't work despite Docker being functional.
Fixes
Fixes #4958