Bobcares

Docker build dns error – Fixed

by | Jan 19, 2020

Is docker build DNS error bothering you? We can help you fix it.

Many times, Docker’s internet connectivity won’t be working properly. This usually happens because of failed DNS lookups in the Docker image.

At Bobcares, we often get the request to solve such errors. Also, we provide fixes for our customers as a part of our Docker Management Services.

Today, let’s analyze the cause and see how our Support Engineers fix the docker build DNS error.

 

What is Docker?

Docker is a tool which makes creating and deploying application easier. Simply, it helps to package up the application as a container. Therefore, all libraries and other needful files are also packed. As a result, it will run on any Linux Machine, regardless of any settings.

Let us discuss how our Support Engineers interpret the common error and how we fix it.

 

Cause and Fix for docker build DNS error?

Recently, one of our customers faced the same problem let’s see the major reason for the error.

Our client tried to build Docker Image but it was failing in Step 2. Therefore, he tried the same in his local PC. It worked in his local PC but while trying in server it failed with the below error message :

docker build dns error

Moreover, the URLs were accessible from the browser and from the network. But from inside docker, it was not resolving.

Firstly, we checked the basic internet connection by pinging a public IP. It was working.

Further, while trying to resolve google.com as sample and received the below error :

$ docker run busybox nslookup google.com
Server: 8.8.8.8
Address 1: 8.8.8.8
nslookup: can't resolve 'google.com'

Certainly, it was failing due to the DNS error. In order to fix it, we used the below command to get the address of DNS Server. For Example, the server was using a local IP 10.0.0.2.

$ nmcli dev show | grep 'IP4.DNS'
IP4.DNS[1]: 10.0.0.2

Now we ran the Docker with this DNS server using the below command :

$ docker run --dns 10.0.0.2 busybox nslookup google.com
Server: 10.0.0.2
Address 1: 10.0.0.2
Name: google.com
Address 1: 2a00:1450:4009:811::200e lhr26s02-in-x200e.1e100.net
Address 2: 216.58.198.174 lhr25s10-in-f14.1e100.net

However, the above solution is temporary. Hence, we have to pass the –dns flag every time during query. To fix it permanently, we set the default option in the Docker Daemon configuration file at
/etc/docker/daemon.json

{
"dns": ["10.0.0.2", "8.8.8.8"]
}

After that, we restarted the docker services using:

sudo service docker restart

Then the docker image builder worked flawlessly.

[Having trouble in fixing docker errors? – We’ll fix it for you.]

Conclusion

In short, docker build DNS error may occur due to multiple reasons. Today, we saw how our Support Engineers fixed errors related to Docker.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.