6

I am following this tutorial

https://docs.docker.com/articles/networking/#between-containers

I have used following commands

$ sudo brctl addbr bridge0
$ sudo ip addr add 192.168.0.160/24 dev bridge0
$ sudo ip link set dev bridge0 up

# Confirming that our bridge is up and running

$ ip addr show bridge0
4: bridge0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP group default
    link/ether 66:38:d0:0d:76:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.160/24 scope global bridge0
       valid_lft forever preferred_lft forever

# Tell Docker about it and restart (on Ubuntu)

$ echo 'DOCKER_OPTS="-b=bridge0"' >> /etc/default/docker
$ sudo service docker start

It looks to work fine as i can see that my all conatiner are getting ip in that range.

Now as i have 3 conatiners

mysql 192.168.0.3
redis 192.168.0.5
webserver 192.168.0.6

Now if i ping redis from webserver it works

but i cma not able to ping the host 192.168.0.160 it says destination host unrecable

INFO

vagrant@ubuntu-docker-base:/mydocker/containers$ brctl show
bridge name bridge id       STP enabled interfaces
bridge0  8000.7e8945d   no  veth1a8b959
                            veth404a3b2
                            veth7959157
docker0     8000.5689799    no

container

root@286329032cd5:/# ip route
default via 192.168.0.160 dev eth0
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.5
root@286329032cd5:/# ping 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_seq=1 ttl=64 time=0.125 ms
64 bytes from 192.168.0.3: icmp_seq=2 ttl=64 time=0.130 ms
64 bytes from 192.168.0.3: icmp_seq=3 ttl=64 time=0.072 ms
^C
--- 192.168.0.3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.072/0.109/0.130/0.026 ms
root@286329032cd5:/# ping 192.168.0.160
PING 192.168.0.160 (192.168.0.160) 56(84) bytes of data.
From 192.168.0.5 icmp_seq=1 Destination Host Unreachable
From 192.168.0.5 icmp_seq=2 Destination Host Unreachable
From 192.168.0.5 icmp_seq=3 Destination Host Unreachable
^C
--- 192.168.0.160 ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5032ms
pipe 3
root@286329032cd5:/#
  • what is the host ip of the machine in which root@286329032cd5:/# ip route – rjt Jan 13 '15 at 5:20
  • @rjt The host ip is 192.168.0.8 which is docker host, which is connected to my router on eth0 – Mirage Jan 13 '15 at 5:24
2

I had a similar problem, where I wanted to connect from a docker container to its host for accessing a postfix and an apache server.

It helped to add such rules to the iptables of the host:

iptables -A INPUT -i docker0 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A INPUT -i docker0 -p tcp -m tcp --dport 80 -j ACCEPT

These ports were open before, but only for eth0 interface, not for docker0 ;)

0

From your manual:

If you already have Docker up and running with its old docker0 still configured, you will probably want to begin by stopping the service and removing the interface:

# Stopping Docker and removing docker0

$ sudo service docker stop
$ sudo ip link set dev docker0 down
$ sudo brctl delbr docker0
  • What is the output of $ cat /proc/sys/net/ipv4/ip_forward on the host? – rjt Jan 13 '15 at 5:23
  • I checked that its 1. i will try your fix when i go home. i was doing remotely and i think i meesed up with eth0 and now i have lost connectivity :) – Mirage Jan 13 '15 at 5:25
  • Now that i have reread more of the tutorial, this answer most likely does not apply. – rjt Jan 13 '15 at 5:36
0

I had this problem when running hello-world-nginx image from kitematic

If I run it from Docker terminal as follows, I am able to view the container output HTML from my Windows browser:

docker run -p 80:80 hello-world-nginx

The -p option forwards port 80 on VirtualBox to port 80 on the container.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.