Running Docker on two hosts, bridged with Open vSwitch
This Gist shows how to use Open vSwitch to bridge Docker containers on two hosts. It is based on this blog post http://goldmann.pl/blog/2014/01/21/connecting-docker-containers-on-multiple-hosts/.
A similar Gist using Tinc instead of Open vSwitch is available: https://gist.github.com/noteed/11031504.
To prepare a host (e.g. a new Digital Ocean Ubuntu 14.04 droplet), simply run
# wget https://gist.githubusercontent.com/noteed/8656989/raw/install.sh # sh install.sh
Once done, the two first variables of the
must be changed, and the script can be run:
# vim shared-docker-network.sh # sh shared-docker-network.sh
Repeat the steps on a second host.
See the other Gist using Tinc to solve a problem where Docker allocates the same IP addresses on both hosts.
Useful debugging commands
root@node-1:~# ip a s root@node-1:~# ip r s root@node-1:~# brctl show root@node-1:~# ovs-vsctl show root@node-1:~# ping <other host> root@node-1:~# ping <other host bridge>