$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e6ad8f3d6a5 weaveworks/plugin:1.9.4 "/home/weave/plugin" 29 seconds ago Up 29 seconds weaveplugin 32826b6869b1 weaveworks/weaveexec:1.9.4 "/home/weave/weave..." 30 seconds ago Up 29 seconds weaveproxy c2c8367fa831 weaveworks/weave:1.9.4 "/home/weave/weave..." 31 seconds ago Up 31 seconds weave
另外还会生成一个名字叫weave的网桥,另一个是Docker默认生成的。
1 2 3 4
$ brctl show bridge name bridge id STP enabled interfaces docker0 8000.0242b3b4de11 no weave 8000.e27709980978 no vethwe-bridge
$ docker network ls NETWORK ID NAME DRIVER SCOPE 515a6b8ba17d bridge bridge local 0b703c3d9cb8 host host local abdb4b9f751c none null local 71cc68f68786 weave weavemesh local
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 63a397f83e3f weaveworks/plugin:1.9.4 "/home/weave/plugin" 3 minutes ago Up 3 minutes weaveplugin e4cb27a9145e weaveworks/weaveexec:1.9.4 "/home/weave/weave..." 3 minutes ago Up 3 minutes weaveproxy eef753a60897 weaveworks/weave:1.9.4 "/home/weave/weave..." 3 minutes ago Up 3 minutes weave
$ docker exec c2 ping -c 3 c1 PING c1 (10.32.0.1): 56 data bytes 64 bytes from 10.32.0.1: seq=0 ttl=64 time=1.307 ms 64 bytes from 10.32.0.1: seq=1 ttl=64 time=0.600 ms 64 bytes from 10.32.0.1: seq=2 ttl=64 time=0.700 ms --- c1 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.600/0.869/1.307 ms
从c1上ping c2
1 2 3 4 5 6 7 8 9 10
$ docker exec c1 ping -c 3 c2
PING c2 (10.44.0.0): 56 data bytes 64 bytes from 10.44.0.0: seq=0 ttl=64 time=0.401 ms 64 bytes from 10.44.0.0: seq=1 ttl=64 time=0.538 ms 64 bytes from 10.44.0.0: seq=2 ttl=64 time=0.891 ms
--- c2 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.401/0.610/0.891 ms
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
使用weave env命令运行容器
1 2 3
$ eval $(weave env) $ docker run --name c1 -it busybox sh $ docker run --name c2 -it busybox sh
测试方法和使用weave run命令类似,这里就不展开讲了。
使用weave plugin方式运行容器
1 2 3 4 5 6 7 8 9 10 11
$ docker run --net=weave --name c1 -it busybox sh
/ # ping -c 3 10.44.0.0 PING 10.44.0.0 (10.44.0.0): 56 data bytes 64 bytes from 10.44.0.0: seq=0 ttl=64 time=0.511 ms 64 bytes from 10.44.0.0: seq=1 ttl=64 time=0.375 ms 64 bytes from 10.44.0.0: seq=2 ttl=64 time=0.703 ms
--- 10.44.0.0 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.375/0.529/0.703 ms
1 2 3 4 5 6 7 8 9 10 11
$ docker run --net=weave --name c2 -it busybox sh
/ # ping -c 3 10.32.0.1 PING 10.32.0.1 (10.32.0.1): 56 data bytes 64 bytes from 10.32.0.1: seq=0 ttl=64 time=0.551 ms 64 bytes from 10.32.0.1: seq=1 ttl=64 time=0.710 ms 64 bytes from 10.32.0.1: seq=2 ttl=64 time=0.556 ms
--- 10.32.0.1 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.551/0.605/0.710 ms
默认情况下不会使用weave的DNS,故不能用容器名进行访问。如果要使用容器主机名,可按以下方法:
1 2 3 4 5 6 7 8 9 10 11
$ docker run --net=weave -h c1.weave.local $(weave dns-args) -ti busybox sh
/ # ping -c3 c2 PING c2 (10.44.0.0): 56 data bytes 64 bytes from 10.44.0.0: seq=0 ttl=64 time=0.472 ms 64 bytes from 10.44.0.0: seq=1 ttl=64 time=0.391 ms 64 bytes from 10.44.0.0: seq=2 ttl=64 time=0.861 ms
--- c2 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.391/0.574/0.861 ms
/ # ping -c3 c1 PING c1 (10.32.0.1): 56 data bytes 64 bytes from 10.32.0.1: seq=0 ttl=64 time=0.411 ms 64 bytes from 10.32.0.1: seq=1 ttl=64 time=0.393 ms 64 bytes from 10.32.0.1: seq=2 ttl=64 time=0.428 ms
--- c1 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.393/0.410/0.428 ms
/ # ping -c3 c6 PING c6 (10.40.0.128): 56 data bytes 64 bytes from 10.40.0.128: seq=0 ttl=64 time=0.051 ms 64 bytes from 10.40.0.128: seq=1 ttl=64 time=0.049 ms 64 bytes from 10.40.0.128: seq=2 ttl=64 time=0.048 ms
--- c6 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.048/0.049/0.051 ms