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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF