0

I have a number of Docker containers running on the same host, but they can't seem to communicate directly using their respective hostnames/container names:

$ docker run -d -t --name test busybox

$ docker run bash nslookup test
Server:         10.10.10.10
Address:        10.10.10.10:53

** server can't find test: NXDOMAIN

** server can't find test: NXDOMAIN

How does the internal DNS normally work for Docker? The containers are on the same network and can communicate using their IP addresses without any issues.

The nameserver configured within the containers is automatically inherited from the host:

$ docker exec -t test cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
# ......

nameserver 10.10.10.10
options edns0 trust-ad
Subbeh
  • 886
  • 2
  • 7
  • 14
  • 1
    You need to `docker network create` a network, and `docker run --net` the container(s) on that network. Without a `--net` option, you wind up on a very old Docker networking mode that doesn't work the way you expect. – David Maze Jan 16 '23 at 12:16

0 Answers0