Using Openvswitch for cross-host Docker container interconnection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.