dockerdevops

My docker container has no internet


I had it working allright but now it stopped. I tried the following commands with no avail:

docker run -dns 8.8.8.8 base ping google.com

docker run base ping google.com

sysctl -w net.ipv4.ip_forward=1 - both on the host and on the container

All I get is unknown host google.com. Docker version 0.7.0

Any ideas?

P.S. ufw disabled as well


Solution

  • Fixed by following this advice:

    [...] can you try to reset everything?

    pkill docker
    iptables -t nat -F
    ifconfig docker0 down
    brctl delbr docker0
    docker -d
    

    It will force docker to recreate the bridge and reinit all the network rules

    https://github.com/dotcloud/docker/issues/866#issuecomment-19218300

    Seems the interface was 'hung' somehow.

    Update for more recent versions of docker:

    The above answer might still get the job done for you but it has been quite a long time since this answer was posted and docker is more polished now so make sure you try these first before going into mangling with iptables and all.

    sudo service docker restart or (if you are in a linux distro that does not use upstart) sudo systemctl restart docker