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