0

I've stuck with a problem of a very slow DNS resolution inside docker container. Simple GET to a 'google.com' takes about 4s to finish while the same request on host takes 0.052 ms. Also request works perfectly if I send it to an IP address that's why I suggested DNS problem. I've searched for an answer most of them were about setting dns servers in a /etc/docker/daemon.json which I did but that didn't help my problem. Server runs on Ubuntu 16.04. I also have a dev server which runs same configurations but it works fine.

Host:

time curl -g 'google.com'

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

real    0m0.052s
user    0m0.004s
sys 0m0.004s

time nslookup google.com

Server:     188.93.16.19
Address:    188.93.16.19#53

Non-authoritative answer:
Name:   google.com
Address: 173.194.73.102
Name:   google.com
Address: 173.194.73.139
Name:   google.com
Address: 173.194.73.100
Name:   google.com
Address: 173.194.73.113
Name:   google.com
Address: 173.194.73.138
Name:   google.com
Address: 173.194.73.101


real    0m0.013s
user    0m0.004s
sys 0m0.004s

Container:

time curl -g https://google.com

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

real    0m4.592s
user    0m0.004s
sys 0m0.012s

time nslookup google.com

Server:     127.0.0.11
Address:    127.0.0.11#53

Non-authoritative answer:
Name:   google.com
Address: 64.233.165.139
Name:   google.com
Address: 64.233.165.101
Name:   google.com
Address: 64.233.165.102
Name:   google.com
Address: 64.233.165.113
Name:   google.com
Address: 64.233.165.100
Name:   google.com
Address: 64.233.165.138


real    0m4.029s
user    0m0.008s
sys 0m0.004s

daemon.json:

{
    "dns": ["188.93.16.19", "188.93.17.19", "8.8.8.8", "8.8.8.4"]
}

3 Answers 3

0

Solved the problem by removing every DNS server except 8.8.8.8 from daemon.json. This is the only one server that resolves domain fast in my case. Tested differrent servers via docker run --dns=<dns server> <image name> curl -g 'google.com'.

0

I was having this issue while using docker-compose. It was a dns issue as well. I added:

services: 
  my_app:
    dns:
      - 8.8.8.8
      - 4.4.4.4

To my docker-compose.yml and it fixed the performance issue.

0

I believe it is related to the bridge MAC address issue as outlined here. You have to add a dummy interface with low MAC address as a slave to the bridge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.