Commit 9104105
authored
[Bug]: Error starting container when using DIND in Kubernetes pod #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.1 parent 73726f4 commit 9104105
File tree
1 file changed
+37
-1
lines changed- core/src/main/java/org/testcontainers/dockerclient
1 file changed
+37
-1
lines changedLines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
18 | 54 | | |
19 | 55 | | |
20 | 56 | | |
| |||
0 commit comments