Skip to content

Conversation

@jtuglu1
Copy link
Contributor

@jtuglu1 jtuglu1 commented Jan 14, 2026

Description

Embedded tests that rely on using useContainerFriendlyHostname() would fail in non-containerized environments since InetAddress.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 to host.docker.internal fixes 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:

  1. WORKING: Embedded JVM test running on the host contacting a container (e.g. Kafka) running inside Docker.

    • Embedded JVM process would do a connect(InetAddress.getLocalHost().getHostAddress():<docker gateway port>) which would resolve to connect(localhost:<docker gateway port>).
    • Docker gateway would then proxy the request to the container process listening on another port.
    • This scenario works fine, since InetAddress.getLocalHost().getHostAddress() actually resolves to what we want. host.docker.internal will also resolve to localhost in this scenario.
  2. WORKING: Container contacting another container

  3. NOT WORKING: Container (e.g. Kafka) wants to reply to that embedded JVM process.

    • It too callsInetAddress.getLocalHost().getHostAddress(), but since they are using separate network namespaces, this resolves to localhost as well (incorrect). Instead, resolving to DockerClientFactory.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:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@jtuglu1 jtuglu1 requested a review from kfaraz January 14, 2026 07:00
@jtuglu1 jtuglu1 force-pushed the fix-container-aware-host-resolution-in-multi-platform-build-envs branch from 237abaa to 3988ce8 Compare January 14, 2026 07:03
@jtuglu1 jtuglu1 changed the title Fix containerFriendly networking in DinD/Linux native environments Fix containerFriendly networking in DinD/VM environments Jan 14, 2026
@jtuglu1 jtuglu1 force-pushed the fix-container-aware-host-resolution-in-multi-platform-build-envs branch from 3988ce8 to e1fed56 Compare January 14, 2026 07:52
@jtuglu1 jtuglu1 force-pushed the fix-container-aware-host-resolution-in-multi-platform-build-envs branch from e1fed56 to bdb0258 Compare January 14, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants