Docker container communication with ovs
2015-11-12 11:35 DoPeter 阅读(431) 评论(0) 编辑 收藏 举报2台宿主机,192.168.11153,192.168.1.154
安装OVS
rpm -ivh openvswitch-2.4.0-1.x86_64.rpm #预先下载的
配置OVS
1. 按照上一篇的内容配置Docker0的IP
http://www.cnblogs.com/dopeter/p/4942606.html
2. 配置OVS
153机器
ovs-vsctl add-br br0
ovs-vsctl add-port br0 gre1 -- set interface gre1 type=gre option:remote_ip=192.168.1.154
#添加br0到本地docker0,使得容器流量通过OVS流经tunnel
brctl addif docker0 br0
ip link set dev br0 up
ip link set dev docker0 up
iptables -t nat -F;iptables -F
ip route add 172.18.0.0/16 dev docker0
154机器
ovs-vsctl add-br br0
ovs-vsctl add-port br0 gre1 -- set interface gre1 type=gre option:remote_ip=192.168.1.153
#添加br0到本地docker0,使得容器流量通过OVS流经tunnel
brctl addif docker0 br0
ip link set dev br0 up
ip link set dev docker0 up
iptables -t nat -F;iptables -F
ip route add 172.17.0.0/16 dev docker0
3. 启动Docker
docker run --name 153mysql -e MYSQL_ROOT_PASSWORD=1 mysql
docker run --name 153mysql -e MYSQL_ROOT_PASSWORD=1 mysql
4. 进入Docker 互Ping
docker exec -it 153mysql bin/bash
docker exec -it 154mysql bin/bash
互Ping
有时会出现Redirect Host的情况,但等一下就好了