-
Notifications
You must be signed in to change notification settings - Fork 16
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
[#50] Consider Docker host IP during port mapping resolution #51
base: master
Are you sure you want to change the base?
[#50] Consider Docker host IP during port mapping resolution #51
Conversation
…ution In some cases, 'localhost' might be resolved to IPv6 '::1', while 'containerPort' will grab IPv4 host IP port mapping by default, when Docker maps different ports for host's IPv4 and IPv6 addresses, this might cause timeout errors. To solve this issue, the Docker host is resolved from 'localhost' at container creation time, host IP protocol version is later used to deduce the corresponding port in 'containerPort' function. Additionally, helper 'containerAddress', as well as 'TraceOpenSocket' and 'TraceHttpCall' now operate 'IP' addresses instead of plain 'Text' domains. This should be safe since we only actually consider domains within some Docker network or 'localhost' at the moment.
Nice, thanks for the contribution. Did you research how Java, Ruby and Go testcontainers approach the problem? That being said, the only way this breaks backward compat is by introducing the IP type where it was a Text before? That part of the change can be undone easily, no? Would love to avoid breaking API changes. |
Yeah, but I considered avoiding
with the |
|
I also have a branch with changes that allow exposing a container port on a specific host IP, see serokell@5d5ca97. Let me know if you consider them worth another PR 😅 However, these changes don't directly solve the root problem since |
OTOH, it's quite hard to avoid them, we do |
Sorry for the delay, I’ll take care of this during zurihac.t |
Yeah, sure, no hurry. At the moment I'm ok with using |
@alexbiehl any chance this can get revisited? |
In some cases, 'localhost' might be resolved to IPv6 '::1', while 'containerPort' will grab IPv4 host IP port mapping by default, when Docker maps different ports for host's IPv4 and IPv6 addresses, this might cause timeout errors.
To solve this issue, the Docker host is resolved from 'localhost' at container creation time, host IP protocol version is later used to deduce the corresponding port in 'containerPort' function.
Additionally, helper 'containerAddress', as well as 'TraceOpenSocket' and 'TraceHttpCall' now operate 'IP' addresses instead of plain 'Text' domains. This should be safe since we only actually consider domains within some Docker network or 'localhost' at the moment.
My solution is quite hacky since I was a bit afraid to break backward compatibility, would be happy to hear your feedback
Somewhat resolves #50.