Hi there,
I am totally new to docker. I have installed a brandnew Ubuntu 20.04 LTS Server instance. I then installed docker and could run the Hello World Container successfully. However, I noticed that the DNS resolution fails inside my containers. Googling told me that I could set the DNS server for the docker daemon manually, e.g., by means of the “–dns” option for “docker run”, but that did not help.
My configuration and test output is this:
foouser@ecr:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
addresses:
- 192.168.1.101/22
gateway4: 192.168.0.230
nameservers:
addresses:
- 192.168.0.24
- 192.168.0.14
search:
- my.domain.com
version: 2
foouser@ecr:~$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search my.domain.com
foouser@ecr:~$ nslookup www.google.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: www.google.com
Address: 172.217.18.164
Name: www.google.com
Address: 2a00:1450:4001:806::2004
foouser@ecr:~$ docker run busybox nslookup www.google.com
Server: 192.168.0.24
Address: 192.168.0.24:53
Non-authoritative answer:
Name: www.google.com
Address: 2a00:1450:4001:806::2004
*** Can't find www.google.com: No answer
foouser@ecr:~$ docker run --dns 127.0.0.53 busybox nslookup www.google.com
WARNING: Localhost DNS setting (--dns=127.0.0.53) may fail in containers.
nslookup: write to '127.0.0.53': Connection refused
;; connection timed out; no servers could be reached
foouser@ecr:~$ docker run busybox ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=116 time=6.280 ms
64 bytes from 8.8.8.8: seq=1 ttl=116 time=5.593 ms
64 bytes from 8.8.8.8: seq=2 ttl=116 time=5.573 ms
64 bytes from 8.8.8.8: seq=3 ttl=116 time=5.567 ms
64 bytes from 8.8.8.8: seq=4 ttl=116 time=5.561 ms
64 bytes from 8.8.8.8: seq=5 ttl=116 time=5.442 ms
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss
round-trip min/avg/max = 5.442/5.669/6.280 ms
foouser@ecr:~$
Has anybody any idea what’s going on here and how I can get DNS inside my Containers?