-
-
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
Cannot connect to containers when using docker-in-docker #4596
Comments
Setting |
Thanks for reporting @jameslamine. Thanks a lot for sharing the workaround as well, much appreciated. |
Can you please set your Testcontainers logs to DEBUG level (see here https://www.testcontainers.org/supported_docker_environment/logging_config/) and provide all the logs of the test run? If you would be able to create some kind of local reproducer, this would also be helpful, but I get that this might be challenging or nearly impossible. |
this is normal, as we are not connecting to container's IP, but Docker Gateway on which all ports are exposed
I think these issues are unrelated. What happening is:
Setting I hope this explanation helps understanding what's going on better 👍 |
Thanks, that's helpful. I am running with the testcontainers logs set to debug. Unfortunately the jenkins output is a bit of a mess and it would be a lot of work for me to clean it up and redact any info from it which I should't post publicly. I can tell you that testcontainers detects the docker socket and detects that it's running in a container and detects that the daemon is docker-in-docker rootless. You're right that it's detecting the docker host as Would it be possible to add an extra step to the environment detection where it starts up a docker container and tries to connect to it at both "localhost" and the gateway IP? That would be one option for automatically detecting this sort of environment. Perhaps you could use Another option would be to try to detect that you're running inside of kubernetes and used that to help decide what to do. |
I can confirm that this shows up in the logs:
|
Hey @jameslamine, we are currently focused on investigating the other issues you have linked (which indeed seem to be a different issue) and then we can think about how to improve this use case. Is the |
Yup, |
Great to hear, I will close this issue for now, since using |
I am also facing the similar issue with testcontainers 1.16.0, 1.16.1, 1.16.2 and 1.16.3. Solution work for me is : |
I'm using docker-in-docker inside of kubernetes in jenkins. My containers appear to start up fine, but the host/port never becomes accessible and so testcontainers cannot connect to them.
Everything works fine when I run the tests locally using docker desktop, it's only on when running in jenkins using docker-in-docker that they fail.
The container ip address is
172.17.0.2
but it's trying to connect to172.17.0.1
which is the gateway. Is that normal?I've tested this on both testcontainers 1.16.0 and 1.16.1 and they both fail. This could be related to #4594, except my problem happens on 1.16.0 as well. This also might be related to #4591 although I am not using
TESTCONTAINERS_HOST_OVERRIDE
Here is my test case where I start up an elasticsearch container, log the ipAddress and hostAddress, and then run
docker inspect
and log the results:The test fails due to
Timed out waiting for URL to be accessible (http://172.17.0.1:49154/ should return HTTP 200
:Here is the output of
docker inspect
:Some additional log lines which might help:
Log output from the failed container:
When I run a similar test for postgres, it passes but that's only because the postgres testcontainer uses a log watching wait strategy and doesn't try to connect to the exposed port. If I try to actually connect to the postgres container it fails as well.
My kubernetes podspec is like this:
The text was updated successfully, but these errors were encountered: