-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to Docker running in WSL2 VM if Testcontainers runs on Windows and Docker Desktop is not used #4958
Comments
Thanks for raising this issue @saurabh4studies. If you can't use Docker Desktop, I'd suggest running your tests from within WSL2 instead. There might be ways to manually configure Testcontainers, Windows, Docker, and WSL2 to make your setup work, but we did not yet have time to dive into this topic. |
Thank you @kiview for your insights. |
Add these dependencies:
And change org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy to org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy in .testcontainers.properties
|
Thanks for sharing this workaround @xa4atur. Are you sure you need to define |
Had similar issue, but with @kiview help was manage to resolve it.
My
Docker socket was located in different folder, so it was necessary to set |
Indeed, it is not necessary as docker-java-api is a transitive dependency: https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.16.0 |
I had faced with same issue. The following steps fixed it https://gist.github.com/sz763/3b0a5909a03bf2c9c5a057d032bd98b7, I hope it will help you. |
@saurabh4studies Which version of testcontainers did you used in this case? |
Closing due to it is resolved. |
For me the issue was solved when I stopped using localhost (also tried 127.0.0.1) and used the eth0 address of WSL. My Powershell script to set the DOCKER_HOST environment variable: (problem is that wsl ip is not static)
|
Maybe my note might help someone... How to make WSL Docker accessible from Windows host:Run with Powershell (as admin):
This command returns connection address like docker.client.strategy=org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy
docker.host=tcp://172.25.34.178:2375
# docker.host it's internal wsl IP that should be configured to access in WSL In WSL terminal you should to add address from the previous step to /etc/docker/daemon.json
Restart wsl wih help PowerShell:
Useful links: |
What I've done to make WSL Docker accessible from Windows host is:
|
All I needed to do to get it working was to add:
I'm still not sure why Testcontainers requires the specific eth0 address, everything else worked with just setting DOCKER_HOST to localhost. |
Test container failed to start and throws Exception when try to run test case.
Host system: Windows 10
WSL2 based system: Ubuntu App for windows
Docker installed inside: Ubuntu App for windows
Using WSL2 based Ubuntu App on windows and setup docker in it. We are able to connect containers run inside it from host system i.e. Windows 10 through Ubuntu App IP address and port on which containers are running. In case of test containers it fails and throws below exception
Exception:
Test case file:
Tried to mitigate this issue by modifying
/etc/docker/deamon.json
andC:/Users/myuser/.testcontainers.properties
files and not succeeded./etc/docker/deamon.json:
C:/Users/myuser/.testcontainers.properties:
The text was updated successfully, but these errors were encountered: