Skip to content

Conversation

@marktech0813
Copy link

I updated container-environment detection so we correctly recognize Kubernetes/DIND pods and compute a reachable Docker host IP for unix-socket setups, avoiding “localhost” when inappropriate. This makes Ryuk and published container ports reachable from your test container in K8s+DIND without requiring manual TESTCONTAINERS_HOST_OVERRIDE.

Key change:
In core/src/main/java/org/testcontainers/dockerclient/DockerClientConfigUtils.java, IN_A_CONTAINER now detects containers using multiple heuristics: /.dockerenv, /run/.containerenv, KUBERNETES_SERVICE_HOST, and cgroup hints (“docker”, “kubepods”, “containerd”, “podman”). When true and DOCKER_HOST is a unix socket, Testcontainers will use the Docker bridge gateway instead of localhost, which fits DIND-in-pod networking.

…tcontainers#11139

I updated container-environment detection so we correctly recognize Kubernetes/DIND pods and compute a reachable Docker host IP for unix-socket setups, avoiding “localhost” when inappropriate.
This makes Ryuk and published container ports reachable from your test container in K8s+DIND without requiring manual TESTCONTAINERS_HOST_OVERRIDE.

Key change:
In core/src/main/java/org/testcontainers/dockerclient/DockerClientConfigUtils.java, IN_A_CONTAINER now detects containers using multiple heuristics: /.dockerenv, /run/.containerenv, KUBERNETES_SERVICE_HOST, and cgroup hints (“docker”, “kubepods”, “containerd”, “podman”). When true and DOCKER_HOST is a unix socket, Testcontainers will use the Docker bridge gateway instead of localhost, which fits DIND-in-pod networking.
@marktech0813 marktech0813 requested a review from a team as a code owner November 11, 2025 10:12
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.

1 participant