Fix containerFriendly networking in DinD/VM environments#18915
Open
jtuglu1 wants to merge 2 commits intoapache:masterfrom
Open
Fix containerFriendly networking in DinD/VM environments#18915jtuglu1 wants to merge 2 commits intoapache:masterfrom
jtuglu1 wants to merge 2 commits intoapache:masterfrom
Conversation
237abaa to
3988ce8
Compare
3988ce8 to
e1fed56
Compare
e1fed56 to
bdb0258
Compare
maytasm
approved these changes
Jan 14, 2026
0b006eb to
68ef8bf
Compare
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.
Description
Embedded tests that rely on using
useContainerFriendlyHostname()would fail in non-containerized environments sinceInetAddress.getLocalHost().getHostAddress()returns the IP associated with the machine's hostname in /etc/hosts or DNS. In cloud CI environments this often returns an internal/corporate network IP which isn't routable from inside the container's isolated network bridge. Switching tohost.docker.internalfixes this as this yields the host of the Docker gateway relative to the requesting process' execution context (running in the host or in the container).Scenarios:
WORKING: Embedded JVM test running on the host contacting a container (e.g. Kafka) running inside Docker.
connect(InetAddress.getLocalHost().getHostAddress():<docker gateway port>)which would resolve toconnect(localhost:<docker gateway port>).InetAddress.getLocalHost().getHostAddress()actually resolves to what we want.host.docker.internalwill also resolve to localhost in this scenario.WORKING: Container contacting another container
NOT WORKING: Container (e.g. Kafka) wants to reply to that embedded JVM process.
InetAddress.getLocalHost().getHostAddress(), but since they are using separate network namespaces, this resolves tolocalhostas well (incorrect). Instead, resolving toDockerClientFactory.dockerHostIpAddress()will yield the host of the Docker gateway, which then can proxy the request back to the intended embedded JVM process.Release note
Fix containerFriendly networking in DinD/Linux native environments for embedded tests.
This PR has: