Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Docker image DNS lookup error: How to resolve

by | Nov 17, 2021

Stuck with a Docker image DNS lookup error? Fear not, our Support Team is here with a solution.

At Bobcares, coming up with solutions for queries, big and small is a part of our Server Management Services.

Let’s take a look at how our Support Team resolved the DNS lookup error today.

About DNS lookup errors

Have you been experiencing a number of obscure errors with your applications?? This might be due to Docker’s internet connectivity issues. According to our Support Tech, this may be a result of failing DNS lookups. Resolving this issue will also help you bid adieu to the pesky docker image DNS lookup error.

Narrowing down docker image DNS lookup error

First, we will check the basic internet connectivity by pinging a public IP address. If it succeeds, you will get a similar output as seen below:

$ docker run busybox ping -c 1 192.203.230.10 # Ping a London-based NASA root nameserver PING 192.203.230.10 (192.203.230.10): 56 data bytes 64 bytes from 192.203.230.10: seq=0 ttl=53 time=113.866 ms --- 192.203.230.10 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 113.866/113.866/113.866 ms

After that, let’s try resolving google.com domain as shown below:

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

If you get a “can’t resolve” message as seen above, it indicates a problem with resolving DNS.

Why does docker image DNS lookup error occur?

Before we dive into resolving the issue, let’s take a look at why the DNS lookup errors keep occurring. In fact, a DNS server that is locally defined in the /etc/resolv.conf file, containers by default, use 8.8.8.8, Google’s public DNS server to resolve DNS.

Hence, the error occurs, then this process is interrupted. Interestingly, in some places, network administrators intentionally block public DNS servers to ensure that the network’s own DNS server is used instead.

In such cases, Docker containers that rely on the default configuration are unable to resolve DNS. Thereby making the internet unusable from within those containers.

Quick fix for docker image DNS lookup error

Our Support Engineers have come up with a quick fix to ensure that the docker container runs with a custom DNS server.

  1. First, we will track down the address of the DNS server from within Ubuntu with the following command:
    $ nmcli dev show | grep 'IP4.DNS' 
    IP4.DNS[1]:                       10.0.0.2
  2. Then, we will run a docker container with the DNS server obtained in the previous step. We will include the –dns flag as well with the command as seen below:
    $ 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:4008:811::200e lhr26s02-in-x200e.1e100.net 
    Address 2: 216.58.198.173 lhr25s10-in-f14.1e100.net

Permanent fix for docker image DNS lookup error

If you prefer a more permanent fix, our Support Engineers have that covered as well.

  1. First, we will change the DNS settings of the Docker daemon by creating the daemon configuration file at /etc/docker/daemon.json.
  2. Then, configure the daemon configuration file with a set of two DNS, namely, the network DNS server and the Google DNS server. The latter works as a backup in case the network DNS server is not available.
    /etc/docker/daemon.json:
    {
        "dns": ["10.0.0.2", "8.8.8.8"]
    }
  3. After that, restart the docker service with the following command:
    sudo service docker restart

You can test this fix by pinging google.com from any Docker container without having to override the DNS server. For instance:

$ docker run busybox nslookup google.com 
Server: 10.0.0.2 
Address 1: 10.0.0.2 
Name: google.com 
Address 1: 2a00:1450:4008:811::200e lhr26s02-in-x200e.1e100.net 
Address 2: 216.58.198.173 lhr25s10-in-f13.1e100.net

[Need a hand with another query? Give us a call today.]

Conclusion

At the end of the day, we learned how to resolve the DNS lookup error. The Support Team at Bobcares offered us a quick fix as well as a more permanent fix to resolve the issue.

PREVENT YOUR SERVER FROM CRASHING!

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

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Categories

Tags

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

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

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

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