To install the Openvswitch, please refer to the previous article: http://www.cnblogs.com/xkops/p/5568167.html
Environment:
192.168.3.201 Node1
192.168.3.202 Node2
1. Create the bridge obr0 on Node1, and then increase the port gre0 to Obr0.
Ovs-vsctl ADD-BR Obr0
Ovs-vsctl Add-port obr0 gre0
Ovs-vsctl set interface gre0 Type=gre options:remote_ip=192.168.3.202
Ovs-vsctl Show
Brctl ADDBR Br0
Ifconfig br0 192.168.1.1 netmask 255.255.255.0
Brctl addif br0 Obr0
Brctl Show
2. Create the bridge obr0 on Node2, and then increase the port gre0 to Obr0.
Ovs-vsctl ADD-BR Obr0
Ovs-vsctl Add-port obr0 gre0
Ovs-vsctl set interface gre0 Type=gre options:remote_ip=192.168.3.201
Ovs-vsctl Show
Brctl ADDBR Br0
Ifconfig br0 192.168.2.1 netmask 255.255.255.0
Brctl addif br0 Obr0
Brctl Show
3. Start the container on the Node1 and view the IP address.
Docker run-it--name Cct1 centos/bin/bash --use ctrl+p+q to exit the container, but the container can run in the background.
ip:192.168.1.2
4. Start the container on the Node2 and view the IP address.
Docker run-it--name cct2 centos/bin/bash --use ctrl+p+q to exit the container, but the container can run in the background.
ip:192.168.2.2
5. Add the routing table on Node1 so that Node1 can reach the 192.168.2.0/24 segment defined by Node2.
IP route add 192.168.2.0/24 via 192.168.3.202 Dev eth0
6. Connect to the container on the Node1 and test the connectivity to the container on the Node2.
Docker Attach CentOS
Ping 192.168.2.2
7. Add the routing table on Node2 so that Node2 can reach the 192.168.1.0/24 segment defined by Node1.
IP route add 192.168.1.0/24 via 192.168.3.201 Dev eth0
In this case, if there is no problem, the last node1 and the two containers on the node2 can ping each other.
Using Openvswitch for cross-host Docker container interconnection