3

I recently installed docker on my ubuntu 16.04. I pulled and run hello-world, ubuntu and sinatra images sucessfully, but they cannot connect to the internet I think!!

Example the following errors are thrown

1. In ubuntu image :

 ali@ali-Satellite-M645:~$ sudo docker run ubuntu apt-get update


  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...

 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.

2. And this on sinatra

   ali@ali-Satellite-M645:~$ docker run -i -t  training/sinatra


   root@fd5c3656dd0b:/# ping google.com
   ping: unknown host google.com
   root@fd5c3656dd0b:/# 

So I googled for this, people are talking about a DNS configuration problem which makes image unable to resolve the domain name.

The solution for such problem is to change edit the file /etc/default/docker and put a correct available DNS ip so:

  1. grabbed the DNS ips using network manager :

    nmcli dev show | grep DNS | sed 's/\s\s*/\t/g' | cut -f 2
    

Took the DNS ips : 10.10.10.11 and 10.10.10.10

  1. Edited the file to be like so:

      # Docker Upstart and SysVinit configuration file  
      #
      # THIS FILE DOES NOT APPLY TO SYSTEMD
      #
      #   Please see the documentation for "systemd drop-ins":
      #   https://docs.docker.com/engine/articles/systemd/
    
      # Customize location of Docker binary (especially for development testing).
      #DOCKER="/usr/local/bin/docker"
      # Use DOCKER_OPTS to modify the daemon startup options.
      DOCKER_OPTS="--dns 10.10.10.11 --dns 10.10.10.10 --dns 8.8.8.8"
    
      # If you need Docker to use an HTTP proxy, it can also be  specified here.
      #export http_proxy="http://127.0.0.1:3128/"
    
      # This is also a handy place to tweak where Docker's temporary files go.
      #export TMPDIR="/mnt/bigdrive/docker-tmp"
    
  2. Restarted Docker

       sudo service docker restart
    
  3. retried apt-get update on ubuntu image and ping google.com the same errors are thrown

Any idea for this problem?

Thanks.

Ali Aboud
  • 131

0 Answers0