Weave Networking for DockerΒΆ
Weave creates a virtual network that enables users to connect docker containers on different host and enable their auto-discovery
Install Weave
$ sudo wget -O /usr/local/bin/weave \
https://github.com/weaveworks/weave/releases/download/latest_release/weave
$ sudo chmod a+x /usr/local/bin/weave
Launch weave containers
$ weave launch
This command will internally pull weave router container and run it
Start two application containers on weave network
$ C=$(weave run 10.2.1.1/24 -t -i ubuntu)
$ C12=$(weave run 10.2.1.2/24 -t -i ubuntu)
C
and C12
hold the containerId of the containers created
$ echo $C
29e5ebaa8f0740077338a6d0d28d0760308f1a3ed2f39034392f1d278d96acd2
$ echo $C12
b0764f4e3792650c8664de2b601e00fc6dae211192dedbad36dcf1e0f11214c9
weave run
command will internally run docker run -d
command in order to set the ip address of weave network and start the ubuntu containers.
Test the connection between two containers connected via weave network by using the ping
command
$ docker attach $C
$ ping 10.2.1.2 -c 4
PING 10.2.1.2 (10.2.1.2) 56(84) bytes of data.
64 bytes from 10.2.1.2: icmp_seq=1 ttl=64 time=0.119 ms
64 bytes from 10.2.1.2: icmp_seq=2 ttl=64 time=0.152 ms
64 bytes from 10.2.1.2: icmp_seq=3 ttl=64 time=0.112 ms
64 bytes from 10.2.1.2: icmp_seq=4 ttl=64 time=0.104 ms
--- 10.2.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.104/0.121/0.152/0.022 ms