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 … 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 example.com is set, for instance, the DNS logic will not only look up host but also host.example.com.