Troubleshoot docker connectivity to external network

This was a DNS server issue — the default server 8.8.8.8 (as pre-configured in Docker in Ubuntu) could be pinged but not reached via nslookup.

I’m having trouble to connect to the internet from a container on my local installation.

  • docker cp from host to container is not working
  • Check for updated package via yum in Dockerfile
  • Is it a bad idea to use docker to run a front end build process during development?
  • fatal: destination path '/home/ipy/ipynotebooks/soccer' already exists and is not an empty directory
  • Can not start docker on lubuntu “cannot start container: exec format error”
  • Why is Internal memory in java Native Memory Tracking increasing
  • My system

    ifconfig looks fine

    $ docker run -ti twelly/ifconfigme ifconfig
    eth0      Link encap:Ethernet  HWaddr f2:bd:a6:53:6f:5f  
              inet addr:172.17.0.35  Bcast:0.0.0.0  Mask:255.255.0.0
              inet6 addr: fe80::f0bd:a6ff:fe53:6f5f/64 Scope:Link
              UP BROADCAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:2 overruns:0 frame:0
              TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:0 (0.0 B)  TX bytes:90 (90.0 B)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    

    I can ping 8.8.8.8

    $ docker run -ti twelly/ifconfigme ping -c 3 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=33.6 ms
    64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=33.6 ms
    64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=33.5 ms
    
    --- 8.8.8.8 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    rtt min/avg/max/mdev = 33.525/33.597/33.650/0.218 ms
    

    ping exits with failure after a timeout

    $ time docker run -ti twelly/ifconfigme ping -c 3 google.com
    ping: unknown host google.com
    
    real    0m40.267s
    user    0m0.014s
    sys 0m0.012s
    

    I have the same results with debian:latest, but I cannot test ifconfig because it’s not installed there.

    New VM

    The same setting works in a new Ubuntu Utopic 14.10 virtual machine.

    Vagrantfile:

    Vagrant.configure(2) do |config|
      config.vm.box = "https://cloud-images.ubuntu.com/vagrant/utopic/current/utopic-server-cloudimg-amd64-vagrant-disk1.box"
    
      config.vm.provision "shell", inline: "apt-get update && apt-get upgrade -y"
      config.vm.provision "shell", inline: "apt-get install -y docker.io && adduser vagrant docker"
    end
    

    Command

    $ vagrant up && vagrant ssh -c "docker run -ti twelly/ifconfigme ping -c 3 google.com"
    

    Question

    What am I possibly doing wrong? How to troubleshoot this?

  • Why is a shell within a docker container showing dmesg content from the host?
  • Sharing a configuration file to multiple docker containers
  • Am I using flyway wrong?
  • High Level Docker and Dockerfile Volume/writeout understanding
  • chown docker volumes on host (possibly through docker-compose)
  • Intermittent Connection Errors for Docker Swarm Services
  • One Solution collect form web for “Troubleshoot docker connectivity to external network”

    You will have to specify that you don’t want that the connectivity to be managed by the container. Use --net=host in your run command.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.