Docker Community Forums

Share and learn in the Docker community.

Bridge network does not work


(Davidphan) #1

I just started using Docker. I found that the bridge network does not allow my container to connect to the outside world. I couldn’t ping google.com. I couldn’t run apt-get update either. However, I could run these commands from the host, which is a VM, running Ubuntu 15.10.

When I ran ‘docker run -it --net=host ubuntu /bin/bash’ then I was able to ping google.com and run apt-get update from within my container.

Executing ‘sudo iptables -t nat -L -n’ would give me the following:

Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DOCKER all – 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DOCKER all – 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all – 172.17.0.0/16 0.0.0.0/0

Chain DOCKER (2 references)
target prot opt source destination
RETURN all – 0.0.0.0/0 0.0.0.0/0

I don’t believe this is an DNS issue, as I have tried the --dns 8.8.8.8 --dns 8.8.4.4 using the DOCKER_OPTS within the /etc/default/docker file and that didn’t change anything.

I believe that somehow the bridge network is unsuccessful opening a connection from the container to the host and outside.

Any help is appreciated.