Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

fix create_bridge() bug, patch README install recipe, WEAVE_DOCKER_ARGS=... #103

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ To run weave on a host, you need to install...
sudo wget -O /usr/local/bin/weave \
https://raw.githubusercontent.com/zettio/weave/master/weaver/weave
sudo chmod a+x /usr/local/bin/weave
/usr/bin/docker pull zettio/weave

3. (recommended) ethtool. On many systems this is installed already;
if not then grab it via your favourite package manager. On some
Expand All @@ -55,14 +56,18 @@ two containers, one on each host.

On $HOST1 run (as root)

host2# export WEAVE_DOCKER_ARGS='--memory=1gb'
host1# weave launch 10.0.0.1/16
host1# C=$(weave run 10.0.1.1/24 -t -i ubuntu)

The first line starts the weave router, in a container. This needs to
The first line sets additional arguments intended to be passed along
to the `docker run` command which launches the weave container.

The next line starts the weave router, in a container. This needs to
be done once on each host. We tell weave that its IP address should
be 10.0.0.1, and that the weave network is on 10.0.0.0/16.

The second line starts our application container. We give it an IP
The third line starts our application container. We give it an IP
address and network (a subnet of the weave network). `weave run`
invokes `docker run -d` with all the parameters following the IP
address and netmask. So we could be launching any container this way;
Expand All @@ -79,6 +84,8 @@ unique.

We repeat similar steps on $HOST2...

host2# export HOST1='<host1_ip_routable_from_host2>'
host2# export WEAVE_DOCKER_ARGS='--memory=1gb'
host2# weave launch 10.0.0.2/16 $HOST1
host2# C=$(weave run 10.0.1.2/24 -t -i ubuntu)

Expand All @@ -87,7 +94,7 @@ weave that it should peer with the weave running on $HOST1. We could
instead have told the weave on $HOST1 to connect to $HOST2, or told
both about each other. Order doesn't matter here; weave automatically
(re)connects to peers when they become available. Also, we can tell
weave to connect to multiple peers by supplying multiple
weave to connect to multiple peers by supplying multiple space delimited
addresses. And we can [add peers dynamically](#dynamic-topologies).

If there is a firewall between $HOST1 and $HOST2, you must open port
Expand Down
17 changes: 11 additions & 6 deletions weaver/weave
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ command_exists () {

[ $# -gt 0 ] || usage

WEAVE_IMAGE='zettio/weave'
BRIDGE=weave
CONTAINER_IFNAME=ethwe
MTU=65535

# `export WEAVE_DOCKER_ARGS='customer arguments'`
# prior to weave launch will permit you to pass along arguments
# to the `docker run` command used to launch the weave container

COMMAND=$1

shift 1
Expand Down Expand Up @@ -75,7 +80,7 @@ add_nat_rule() {

create_bridge() {
[ ! -d /sys/class/net/$BRIDGE ] && {
ip link add dev $BRIDGE type bridge
ip link add name $BRIDGE type bridge
ip link set dev $BRIDGE address 7a:$(od -txC -An -N5 /dev/random | tr \ : | tail -c+2)
# Attempting to set the bridge MTU to a high value directly
# fails. Bridges take the lowest MTU of their interfaces. So
Expand Down Expand Up @@ -229,11 +234,11 @@ case "$COMMAND" in
IPADDR=$1
shift 1
case $(docker inspect --format '{{ .State.Running }} {{ .Config.Image }}' weave 2>/dev/null) in
"true zettio/weave")
"true $WEAVE_IMAGE")
echo "Weave is already running." >&2
exit 1
;;
"false zettio/weave")
"false $WEAVE_IMAGE")
docker rm weave >/dev/null
;;
true*)
Expand All @@ -255,7 +260,7 @@ case "$COMMAND" in
# (eth0, wlan0, etc) so the name becomes stable across host
# restarts.
MACADDR=`cat /sys/class/net/$BRIDGE/address`
CONTAINER=$(docker run --privileged -d --name=weave -p 6783:6783/tcp -p 6783:6783/udp $WEAVE_DOCKER_ARGS zettio/weave -name $MACADDR "$@")
CONTAINER=$(docker run --privileged -d --name=weave -p 6783:6783/tcp -p 6783:6783/udp $WEAVE_DOCKER_ARGS $WEAVE_IMAGE -name $MACADDR "$@")
with_container_netns attach $CONTAINER $IPADDR eth0
echo $CONTAINER
;;
Expand All @@ -280,8 +285,8 @@ case "$COMMAND" in
version)
# Try the running container first; if no luck try the image
if ! DOCKERIMAGE=$(docker inspect --format='{{ .Image }}' weave 2>/dev/null) ; then
if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' zettio/weave 2>/dev/null) ; then
echo "Unable to find zettio/weave image." >&2
if ! DOCKERIMAGE=$(docker inspect --format='{{ .Id }}' $WEAVE_IMAGE 2>/dev/null) ; then
echo "Unable to find $WEAVE_IMAGE image." >&2
exit 1
fi
fi
Expand Down