When you experience problems with networking inside Docker images, it could be there is a problem with the docker networking. To reset it, do this:

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

(Taken from here: https://github.com/moby/moby/issues/866#issuecomment-19218300)