LKE: Reach host ip from a nested docker-out-of-docker container
Hi, does Jerome Petazonni still work for Linode? He wrote a solution and tutorial on spinning nested docker containers. We have a jenkins CI/CD running on a LKE cluster, that needs to spawn dockerised test containers for test databases. The solution we've opted for is Docker-Out-Of-Docker (dood), via the host node's docker.sock. The question I have concerns networking. We can spin nester sub-containers fine, but we're not sure how to reach them by hostname/ip. How does one reach the databases and other services running on the host?
1 Reply
Apologies, I assumed Jerome was internal staff as he's on a LKE demo. No matter, I have found the solution. The solution is that the host docker machine is accessible via the default docker gateway on 172.17.0.1. One can chose to hit that directly, or mirror Macos and Windows and create an alias in /etc/hosts for "host.docker.internal", or better yet also add an alias for service name ex (" 172.17.0.1 host.docker.internal mysql") and then connect to mysql:3306 (for a single mysql running on the default port).