Warm tip: This article is reproduced from serverfault.com, please click

Why is network/internet in my Docker container so slow?

发布于 2017-01-29 17:01:16

I'm asking this question because it took me ages to figure out why the networking in my base ubuntu container was so slow, up to 50 times slower than the host OS, which made any kind of apt-get installations take extremely long (45+ minutes in some cases).

How can I make the networking in my container faster?

Questioner
Christopher Shroba
Viewed
0
Christopher Shroba 2018-06-07 22:41:43

Simply changing my DNS server instantly fixed the problem. Previously, DNS lookups were taking 5+ seconds, and now they're <.1 second.

Just change the nameserver lines in /etc/resolv.conf to:

nameserver 8.8.8.8
nameserver 8.8.4.4

which is Google's DNS Server.

Wanted to post this answer here because I couldn't find this advice anywhere online, and it made a night and day difference for me.

You can also specify the dns server as an argument to docker run. For example:

docker run --dns 8.8.8.8 <container name>