Update README examples to use IPAM and DNS

This commit is contained in:
Adam Harrison committed 2015-06-17 17:32:40 +01:00
1 parent d09133c010
commit cf5835f081
1 file changed
+35 -41
+35 -41
View File
@@ -55,47 +55,41 @@ two containers, one on each host.
On `$HOST1` run On `$HOST1` run
host1$ weave launch host1$ weave launch
host1$ C=$(weave run 10.2.1.1/24 -t -i ubuntu) host1$ weave launch-dns
host1$ weave run --name h1c1 -t -i ubuntu
The first line starts the weave router, in a container. This needs to The first two lines start the weave router and DNS, each inside their
be done once on each host. The required docker image for the weave own container - this needs to be done once per host. Whilst the
router container is downloaded automatically. There is also a `weave required docker images are downloaded automatically, there is also a
setup` command for downloading this and other images required for `weave setup` command for downloading all the images required for
weave operation; this is a strictly optional step which is especially weave operation; this is a strictly optional step which is especially
useful for automated installation of weave and ensures that any useful for automated installation of weave and ensures that any
subsequent weave commands do not encounter delays due to image subsequent weave commands do not encounter delays due to image
downloading. downloading.
The second line runs our application container. We give it an IP The third line runs our application container, allocating it an IP
address and network, in address on the weave network and registering it in DNS. `weave run`
[CIDR notation](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation). invokes `docker run -d` behind the scenes, so we could be launching
`weave run` invokes `docker run -d` with all the parameters following any container this way; here we just take a stock ubuntu container and
the IP address and network. So we could be launching any container launch a shell in it. There's also a `weave start` command, which
this way; here we just take a stock ubuntu container and launch a invokes `docker start` for starting existing containers.
shell in it. There's also a `weave start` command, which invokes
`docker start` for starting existing containers.
If our application consists of more than one container on this host we If our application consists of more than one container on this host we
simply launch them with a variation on that second line. simply launch them with a variation on third second line.
The IP addresses and netmasks can be anything you like, but make sure Next we repeat similar steps on `$HOST2`...
they don't conflict with any IP ranges in use on the hosts or IP
addresses of external services the hosts or containers need to connect
to. The same IP range must be used everywhere, and the individual IP
addresses must, of course, be unique.
We repeat similar steps on `$HOST2`...
host2$ weave launch $HOST1 host2$ weave launch $HOST1
host2$ C=$(weave run 10.2.1.2/24 -t -i ubuntu) host2$ weave launch-dns
host2$ weave run --name h2c1 -t -i ubuntu
The only difference, apart from the choice of IP address for the The only difference, apart from the name of the application container,
application container, is that we tell our weave that it should peer is that we tell our weave that it should peer with the weave on
with the weave on `$HOST1` (specified as the IP address or hostname, `$HOST1` (specified as the IP address or hostname, and optional
and optional `:port`, by which `$HOST2` can reach it). NB: if there is `:port`, by which `$HOST2` can reach it). NB: if there is a firewall
a firewall between `$HOST1` and `$HOST2`, you must open the weave port between `$HOST1` and `$HOST2`, you must open the weave port (6783 by
(6783 by default; this can be overriden by setting `WEAVE_PORT`) for default; this can be overriden by setting `WEAVE_PORT`) for TCP and
TCP and UDP. UDP.
Note that we could instead have told the weave on `$HOST1` to connect to Note that we could instead have told the weave on `$HOST1` to connect to
`$HOST2`, or told both about each other. Order does not matter here; `$HOST2`, or told both about each other. Order does not matter here;
@@ -109,21 +103,21 @@ can talk to each other...
On `$HOST1`... On `$HOST1`...
host1$ docker attach $C host1$ docker attach h1c1
root@28841bd02eff:/# ping -c 1 -q 10.2.1.2 root@h1c1:/# ping -c 1 -q h2c1
PING 10.2.1.2 (10.2.1.2): 48 data bytes PING h2c1.weave.local (10.160.0.2) 56(84) bytes of data.
--- 10.2.1.2 ping statistics --- --- h2c1.weave.local ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss 1 packets transmitted, 1 received, 0% packet loss, time 0ms
round-trip min/avg/max/stddev = 1.048/1.048/1.048/0.000 ms rtt min/avg/max/mdev = 0.341/0.341/0.341/0.000 ms
Similarly, on `$HOST2`... Similarly, on `$HOST2`...
host2$ docker attach $C host2$ docker attach h2c1
root@f76829496120:/# ping -c 1 -q 10.2.1.1 root@h2c1:/# ping -c 1 -q h1c1
PING 10.2.1.1 (10.2.1.1): 48 data bytes PING h1c1.weave.local (10.128.0.2) 56(84) bytes of data.
--- 10.2.1.1 ping statistics --- --- h1c1.weave.local ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss 1 packets transmitted, 1 received, 0% packet loss, time 0ms
round-trip min/avg/max/stddev = 1.034/1.034/1.034/0.000 ms rtt min/avg/max/mdev = 0.366/0.366/0.366/0.000 ms
So there we have it, two containers on separate hosts happily talking So there we have it, two containers on separate hosts happily talking
to each other. to each other.