Docker Community Forums

Share and learn in the Docker community.

Docker container should not resolve DNS in Ubuntu 18.04

(Rebaca) #1

Docker container should not resolve DNS in Ubuntu 18.04
I want to access server with name from inside container
Am running a container with --dns flag with host’s DNS server IP
docker run -itd --dns --name test_img

But from inside container am not able access google server

[root@0b86fa7dde50 scripts]# curl
curl: (6) Could not resolve host:; Unknown error
[root@0b86fa7dde50 scripts]#

Host DNS details:
root@rebaca# nslookup

Non-authoritative answer:
Address: 2607:f8b0:4005:805::200e

without that --dns flag in docker run command, am bale to access as because by default container is running with dns server

But am not able to access my consul server with Domain name.

How would i access consul server and google server with domain names without adding details in /etc/hosts file

(Misho Krastev) #2

The lo interface inside the container, the one receiving IP packets destined to, is not the same lo interface of the docker host, i.e. outside the container. Try to connect to the dns server with the nc tool:

nc -v 53

If you see a message saying connection refused that would prove you can not reach the dns server. Instead, use the IP address assigned to the host ethernet (ow wifi) adapter.