6

I am using docker in my Ubuntu host and want to build a costume image with some development packages.

When ever i run

docker run -it ubuntu apt-get update

It doesn't resolve the host and throw below error log

Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done        
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Out put of docker run -it ubuntu more /etc/resolv.conf is

search company.com
nameserver 8.8.8.8
nameserver 8.8.4.4

Note: company.com is my organization domain

out put of docker network inspect bridge is

[
    {
        "Name": "bridge",
        "Id": "ee1a3e8cac6fdc0be630ae027957345b63977b6bb74cec04a9200f1ad8f895f7",
        "Created": "2017-02-09T21:46:05.235449663+05:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]
0

1 Answer 1

9

What worked for me was this guide.

from https://stackoverflow.com/a/40516974 (YOUR_DNS_IP_HERE is my addition)

Put this in /etc/docker/daemon.json:

{                                                                     
    "dns": ["YOUR_DNS_IP_HERE", "YOUR_DNS_IP_HERE"]   
}

Exit from root:

 exit

Now restart docker:

sudo service docker restart

VERIFICATION:

Now check that adding the /etc/docker/daemon.json file allows you to resolve 'google.com' into an IP address:

docker run busybox nslookup google.com
1
  • 1
    For me just sudo service docker restart fixed the problem. Thanks for posting this reply.
    – muammar
    Commented Aug 10, 2020 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .