I'm not sure why DNS resolves slowly in containers, but I have a procedure that I use to resolve DNS in docker containers.
To check the DNS resolution issue:
# docker run busybox nslookup google.com Server: 8.8.8.8 Address 1: 8.8.8.8 nslookup: can't resolve 'google.com'
Find out the DNS server used on your computer :
Run it again using the DNS-IP found in the previous step, which fixes the DNS problem:
# docker run --dns 172.24.100.50 busybox nslookup google.com Server: 172.24.100.50 Address 1: 172.24.100.50 indc01.radisys.com Name: google.com Address 1: 2607:f8b0:4009:80c::200e ord36s01-in-x0e.1e100.net Address 2: 172.217.4.110 ord36s04-in-f14.1e100.net
To permanently resolve it, add the following content as shown below to the new file:
root@labadmin-VirtualBox :/home/labadmin
Learn more about Docker DNS Configuration .
Restart the docker service and confirm it again:
# docker run busybox nslookup google.com Server: 172.24.100.50 Address 1: 172.24.100.50 indc01.radisys.com Name: google.com Address 1: 2607:f8b0:4009:801::200e ord30s31-in-x0e.1e100.net Address 2: 172.217.4.238 ord30s31-in-f14.1e100.net
Test it by running the container:
# docker run -it e02e811dd08f /
Hope this helps.
source share