-
-
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
NetworkMode=host causes starting issue #5151
Comments
I have the same issue... For me as a workaround, I copy-pasted the GenericContainer -class (and dependent classes) from Git, commit of version 1.16.3 - and "reverted" the changes of Commit "Remove withPublishAllPorts from Ryuk and stabilize containerInfo content on start (#4263)"; 034daa6 from 20.07.21 in the class mentioned above. These are the lines where the exception is thrown... The problem has something to do with starting the container with
I hope the fix will come with the next version, so I can remove my workaround-copy-pasted-classes! |
I could confirm the issue and it might be the case for any container exposing ports while using network mode |
I am also affected by this in a certain scenario. Is there any way I can help with this issue? (Information about the env, code, etc.?) |
I think we would need to debug why the check that was introduced with 034daa6 (which did fix certain race condition scenarios, especially on Windows) seems to not apply if network mode is set to |
Looking into this now. What I've found so far is:
The issue is, however, that published (exposed) ports are discarded on network mode
In the above example the code expects
But in reality,
So the container times out and throws an exception. From here, I'm planning to look into the reasoning behind the above code snippet and potential fixes. |
@REslim30 If I remember correctly, parts of this code were refactored in order to remove certain race conditions on Docker Desktop (particularly Docker Desktop on Windows). Your findings make sense, this is likely the issue. |
Thanks for the investigation @REslim30, this is super helpful to proceed with this. Both your points are valid and solution 1 seems very pragmatic. And we can improve on this by documenting this behavior in the Javadoc. The blast radius of solution 2 feels too high for me, to be really feasible. Before talking more about the potential solutions, I would like to circle back to understand the use cases for which to use a container with |
We need that as part of the quite specific pipeline. |
@rgugliel-da Thanks for sharing the context. So this is for solving an issue when using a containerized CI and you using Docker-Socket-Mounting to start sibling containers? I think I don't yet understand how the network setup affects querying the database in this case. Did you consider putting the sibling container on the same Docker network as the containerized test JVM and don't use dynamic port mapping at all, but rely on fixed port and Docker DNS? |
Hey @rgugliel-da, any chance to follow up on my previous question? Or alternatively @javahippie? |
Hi @kiview ,
That's correct.
No, I did not. I went for the current approach because I thought I could use similar setup both locally and on CI. |
I was thinking about using Testcontainers' Advanced Networking Feature. Is there an in the communication of 2 containers started by Testcontainers with each other, or is it about the JVM process communicating with the Oracle container? Edit: |
Situation A. |
Thank you, then it seems we indeed need to support the network mode. I still don't understand why the Oracle container requires it in this setup, but since it worked in old Testcontainers versions we introduced a regression for this feature and I believe we should try to restore the fuctionality. |
@REslim30 Would you like to contribute the fix? Regarding your 2nd proposal, what if we implement your second proposal, but throw a runtime exception, so we don't have to handle all usages of |
Sure, give me one sec. |
@rgugliel-da, @javahippie @pretep22, can I confirm what environments you're on?
I'm considering whether or not to throw an exception (or at least a warning) on non-linux environments when trying to use host mode. |
Ok I've submitted a PR for this. As for:
I've added a separate issue for this. I think there's value in it. #5853 |
I use Ubuntu. |
We close this as not planned, see comment in PR:
|
I'd like to clarify, network mode |
I use the following code to start a container:
With testcontainers
1.15.1
, it works.When updating to
1.16.3
, I get the following error:Any idea what's happening ?
The text was updated successfully, but these errors were encountered: