I understand Docker runs a magical dns on 127.0.0.11, so I figured I'd try
nslookup mycontainername 127.0.0.11
where mycontainername
is, of course, the name of the container I'm trying to access. However, that timed out.
;; connection timed out; no servers could be reached
What am I doing wrong? I'm on Docker 1.10.3. If it helps, I'm pulling up a bunch of containers using docker-compose
1.6.2.
EDIT This is a duplicate of Docker 1.10 access a container by it's hostname from a host machine
Docker is coded in a smart way. When you run new container on the docker host without any DNS related option in command, it simply copies host's /etc/resolv. conf into the container.
Use --network="host" in your docker run command, then 127.0. 0.1 in your docker container will point to your docker host. Note: This mode only works on Docker for Linux, per the documentation.
There is an excellent solution for this and it has been answered in this post: https://stackoverflow.com/a/51125399/9270227. It is basically just a lightweight container called docker-hoster that does all the heavy lifting for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With