Docker Community Forums

Share and learn in the Docker community.

Embedded DNS does not resolve hostnames

Just can’t seem to get containers in the same network to resolve each other’s hostname or container names.

Anybody have any clues? Thank you.

Version 17.09.0-ce
Architecture amd64
Kernel version 3.10.0-327.36.3.el7.x86_64
OS CentOS Linux 7 (Core)

# docker network create -d bridge mybridge01
# docker run -itd --network=mybridge01 --name busybox01 -h busybox01 busybox
# docker run -itd --network=mybridge01 --name busybox02 -h busybox02 busybox
# docker exec -it busybox01 ping -c 2 busybox02
ping: bad address 'busybox02'
1 Like

CentOS Linux release 7.4.1708 x86_64
Docker version 17.09.0-ce, build afdb6d4

Same problem.

After some experiments i found that hostname must be a FQDN :slight_smile: … Or, at least, have at least one dot in the name.

cont1, cont2 = bad address
cont.1, cont.2 = nslookup ok
container-a, container-b = bad address
web, db = bad address
web.domain, db.domain = nslookup ok


I have removed the “search” domains from /etc/resolv.conf (and from interface configuration too) and now i can resolve unqualified container names (cont1, cont2, web, db, etc).
Maybe, specifying “dns-search”: [] in daemon.json or --dns-search=. in container startup parameters?

But docker docs says that i can use unqualified hostnames even if search domains is set:

When a container process attempts to access host and the search domain is set, for instance, the DNS logic will not only look up host but also

Thank you! I’ve been fighting with this for hours and couldn’t figure it out

Thank you so much for this fix! I was about to give up and start reinstalling (and I would have had the same issue).