Merge pull request #388 from squaremo/remote_weaving

Move weave script into tools image with its deps
and thus enable weaving on a remote docker

Closes #312.
This commit is contained in:
rade committed 2015-03-20 15:17:09 +00:00
commit 8e65c7127d
18 files changed
+204 -201

No files matched your search

+2 -1
View File
@@ -35,4 +35,5 @@ tools/build
releases
weave.tar
weavedns.tar
weavetools.tar
weaveexec.tar
weaveexec/docker*.tgz
+19 -24
View File
@@ -1,4 +1,4 @@
PUBLISH=publish_weave publish_weavedns publish_weavetools
PUBLISH=publish_weave publish_weavedns publish_weaveexec
.DEFAULT: all
.PHONY: all update tests publish $(PUBLISH) clean prerequisites build
@@ -10,15 +10,18 @@ DOCKERHUB_USER=zettio
WEAVE_VERSION=git-$(shell git rev-parse --short=12 HEAD)
WEAVER_EXE=weaver/weaver
WEAVEDNS_EXE=weavedns/weavedns
WEAVETOOLS_EXES=tools/bin
WEAVER_IMAGE=$(DOCKERHUB_USER)/weave
WEAVEDNS_IMAGE=$(DOCKERHUB_USER)/weavedns
WEAVETOOLS_IMAGE=$(DOCKERHUB_USER)/weavetools
WEAVEEXEC_IMAGE=$(DOCKERHUB_USER)/weaveexec
WEAVER_EXPORT=weave.tar
WEAVEDNS_EXPORT=weavedns.tar
WEAVETOOLS_EXPORT=weavetools.tar
WEAVEEXEC_EXPORT=weaveexec.tar
all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
WEAVEEXEC_DOCKER_VERSION=1.3.1
DOCKER_DISTRIB=weaveexec/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)
update:
go get -u -f -v -tags -netgo ./$(dir $(WEAVER_EXE)) ./$(dir $(WEAVEDNS_EXE))
@@ -38,18 +41,6 @@ $(WEAVER_EXE) $(WEAVEDNS_EXE): common/*.go
$(WEAVER_EXE): router/*.go weaver/main.go
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go
build_weavetools_exes_in_container=yes
$(WEAVETOOLS_EXES): tools/build.sh
ifdef build_weavetools_exes_in_container
$(SUDO) docker run --rm -t -v $(realpath $(<D)):/home/weave ubuntu sh /home/weave/build.sh
else
rm -rf tools/build
mkdir tools/build
cd tools/build && sh ../../$<
rm -rf tools/build
endif
$(WEAVER_EXPORT): weaver/Dockerfile $(WEAVER_EXE)
$(SUDO) docker build -t $(WEAVER_IMAGE) weaver
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
@@ -58,9 +49,14 @@ $(WEAVEDNS_EXPORT): weavedns/Dockerfile $(WEAVEDNS_EXE)
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) weavedns
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@
$(WEAVETOOLS_EXPORT): tools/Dockerfile $(WEAVETOOLS_EXES)
$(SUDO) docker build -t $(WEAVETOOLS_IMAGE) tools
$(SUDO) docker save $(WEAVETOOLS_IMAGE):latest > $@
$(WEAVEEXEC_EXPORT): weaveexec/Dockerfile $(DOCKER_DISTRIB) weave
cp weave weaveexec/weave
cp $(DOCKER_DISTRIB) weaveexec/docker.tgz
$(SUDO) docker build -t $(WEAVEEXEC_IMAGE) weaveexec
$(SUDO) docker save $(WEAVEEXEC_IMAGE):latest > $@
$(DOCKER_DISTRIB):
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)
# Add more directories in here as more tests are created
tests:
@@ -75,11 +71,10 @@ $(PUBLISH): publish_%:
publish: $(PUBLISH)
clean:
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVETOOLS_IMAGE)
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
$(SUDO) rm -rf $(WEAVETOOLS_EXES)
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVEEXEC_IMAGE)
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)
build:
$(SUDO) go clean -i net
$(SUDO) go install -tags netgo std
$(MAKE) build_weavetools_exes_in_container=
$(MAKE)
+3
View File
@@ -36,6 +36,9 @@ Ensure you are running Linux (kernel 3.5 or later) and have Docker
CoreOS users see [here](https://github.com/fintanr/weave-gs/blob/master/coreos-simple/user-data) for an example of installing weave using cloud-config.
Weave respects the environment variable `DOCKER_HOST`, so you can run
it locally to control a weave network on a remote host.
## Quick Start Screencast
<a href="http://youtu.be/k6r7yuSr0hE" alt="Click to watch the screencast" target="_blank">
+2 -2
View File
@@ -50,8 +50,8 @@ $ make
This will build the weave components and package them into three
Docker images (`zettio/weave`, `zettio/weavedns`, and
`zettio/weavetools`). These are then exported (as
`weave.tar`, `weavedns.tar` and `weavetools.tar`).
`zettio/weaveexec`). These are then exported (as `weave.tar`,
`weavedns.tar` and `weaveexec.tar`).
## Building in a Docker container
+6 -6
View File
@@ -8,16 +8,16 @@ C2=10.2.1.7
start_suite "Ping over cross-host weave network"
for HOST in $HOST1 $HOST2; do
run_on $HOST sudo $WEAVE stop || true
run_on $HOST sudo $WEAVE stop-dns || true
weave_on $HOST stop || true
weave_on $HOST stop-dns || true
docker_on $HOST rm -f c1 c2 || true
done
run_on $HOST1 sudo $WEAVE launch
run_on $HOST2 sudo $WEAVE launch $HOST1
weave_on $HOST1 launch
weave_on $HOST2 launch $HOST1
run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 ubuntu
run_on $HOST1 sudo $WEAVE run $C1/24 -t --name=c1 ubuntu
weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu
weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok")
assert "echo $ok" "ok"
+6 -6
View File
@@ -8,16 +8,16 @@ C2=10.2.1.7
start_suite "Ping over encrypted cross-host weave network"
for HOST in $HOST1 $HOST2; do
run_on $HOST sudo $WEAVE stop || true
run_on $HOST sudo $WEAVE stop-dns || true
weave_on $HOST stop || true
weave_on $HOST stop-dns || true
docker_on $HOST rm -f c1 c2 || true
done
run_on $HOST1 sudo $WEAVE launch -password notverysecure
run_on $HOST2 sudo $WEAVE launch -password notverysecure $HOST1
weave_on $HOST1 launch -password notverysecure
weave_on $HOST2 launch -password notverysecure $HOST1
run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 ubuntu
run_on $HOST1 sudo $WEAVE run $C1/24 -t --name=c1 ubuntu
weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu
weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok")
assert "echo $ok" "ok"
+5 -5
View File
@@ -7,14 +7,14 @@ C2=10.2.0.34
start_suite "Resolve names on a single host"
run_on $HOST1 sudo $WEAVE stop || true
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24
weave_on $HOST1 stop || true
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24
docker_on $HOST1 rm -f c1 c2 || true
run_on $HOST1 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "dig +short seetwo.weave.local")
assert "echo $ok" "$C2"
+8 -8
View File
@@ -8,19 +8,19 @@ C2=10.2.3.34
start_suite "Resolve names across hosts"
for host in $HOST1 $HOST2; do
run_on $host sudo $WEAVE stop || true
run_on $host sudo $WEAVE stop-dns || true
weave_on $host stop || true
weave_on $host stop-dns || true
docker_on $host rm -f c1 c2 || true
done
run_on $HOST1 sudo $WEAVE launch
run_on $HOST2 sudo $WEAVE launch $HOST1
weave_on $HOST1 launch
weave_on $HOST2 launch $HOST1
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 -debug
run_on $HOST2 sudo $WEAVE launch-dns 10.2.254.2/24 -debug
weave_on $HOST1 launch-dns 10.2.254.1/24 -debug
weave_on $HOST2 launch-dns 10.2.254.2/24 -debug
run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
weave_on $HOST2 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
weave_on $HOST1 run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short seetwo.weave.local)
assert "echo $ok" "$C2"
+5 -5
View File
@@ -7,14 +7,14 @@ C2=10.2.54.91
start_suite "Resolve names in custom domain"
run_on $HOST1 sudo $WEAVE stop || true
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 --localDomain foo.bar.
weave_on $HOST1 stop || true
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24 --localDomain foo.bar.
docker_on $HOST1 rm -f c1 c2 || true
run_on $HOST1 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.foo.bar ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.foo.bar ubuntu
weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "dig +short seetwo.foo.bar.")
assert "echo $ok" "$C2"
+3 -3
View File
@@ -4,11 +4,11 @@
start_suite "Resolve a non-weave address"
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 -debug
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24 -debug
docker_on $HOST1 rm -f c1 || true
run_on $HOST1 sudo $WEAVE run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -t MX weave.works)
assert "test -n \"$ok\" && echo pass" "pass"
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
. ./config.sh
start_suite "Run weave with --local"
run_on $HOST1 sudo ./weave --local reset
run_on $HOST1 sudo ./weave --local launch
assert_raises "docker_on $HOST1 ps | grep weave" 0
docker_on $HOST1 rm -f c1 || true
run_on $HOST1 sudo ./weave --local run 10.2.6.5/24 -ti --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ifconfig | grep ethwe")
assert "test -n \"$ok\" && echo pass" "pass"
docker_on $HOST1 rm -f c1 || true
end_suite
+1 -1
View File
@@ -6,7 +6,7 @@ ip_prefix = "192.168.48"
ip_suffix_base = 10
def configure_docker(host, hostname, ip)
pkgs = "lxc-docker"
pkgs = "lxc-docker ethtool"
host.vm.box = "phusion/ubuntu-14.04-amd64"
host.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
+8 -1
View File
@@ -50,6 +50,13 @@ docker_on() {
docker -H tcp://$host:2375 $@
}
weave_on() {
host=$1
shift 1
greyly echo "Weave on $host: $@"
DOCKER_HOST=tcp://$host:2375 $WEAVE $@
}
start_suite() {
whitely echo $@
}
@@ -58,5 +65,5 @@ end_suite() {
whitely assert_end
}
WEAVE=./bin/weave
WEAVE=../weave
DOCKER_NS=./bin/docker-ns
+4 -5
View File
@@ -13,11 +13,10 @@ echo Copying weave images and script to hosts
for HOST in $HOSTS; do
docker_on $HOST load -i ../weave.tar
docker_on $HOST load -i ../weavedns.tar
docker_on $HOST load -i ../weavetools.tar
run_on $HOST mkdir -p `dirname $WEAVE`
cat ../weave | run_on $HOST sh -c "cat > $WEAVE"
docker_on $HOST load -i ../weaveexec.tar
run_on $HOST mkdir -p bin
cat ../bin/docker-ns | run_on $HOST sh -c "cat > $DOCKER_NS"
run_on $HOST chmod a+x $WEAVE
run_on $HOST chmod a+x $DOCKER_NS
cat ../weave | run_on $HOST sh -c "cat > ./weave"
run_on $HOST chmod a+x $DOCKER_NS ./weave
run_on $HOST sudo service docker restart
done
-3
View File
@@ -1,3 +0,0 @@
FROM scratch
MAINTAINER Weaveworks Inc <help@weave.works>
ADD ./bin /bin
-62
View File
@@ -1,62 +0,0 @@
#!/bin/sh
# Show the progress of this script, in case it fails.
set -x -e
sudo apt-get -y update
sudo apt-get -y install curl make pkg-config gcc bison flex
BASEDIR=$(dirname $0)
mkdir -p "$BASEDIR"/bin
copy_exe() {
if ldd $1 >/dev/null 2>&1 ; then
echo "ERROR: $1 was not linked statically." 2>&1
exit 1
fi
cp $1 "$BASEDIR"/bin/
}
# ethtool
ETHTOOL=ethtool-3.16
rm -rf $ETHTOOL
curl -s -S https://www.kernel.org/pub/software/network/ethtool/$ETHTOOL.tar.gz | tar xvz
(cd $ETHTOOL; ./configure LDFLAGS=-static && make)
copy_exe $ETHTOOL/ethtool
# conntrack
PACKAGES="libmnl-1.0.3 libnfnetlink-1.0.1 libnetfilter_cttimeout-1.0.0 libnetfilter_cthelper-1.0.0 libnetfilter_queue-1.0.2 libnetfilter_conntrack-1.0.4"
CONNTRACK=conntrack-tools-1.4.2
rm -rf $PACKAGES $CONNTRACK
fetch() {
curl -s -S http://www.netfilter.org/projects/${1%-*}/files/$1.tar.bz2 | tar xj
}
for PACKAGE in $PACKAGES; do
fetch $PACKAGE
(cd $PACKAGE; ./configure --disable-shared && make && sudo make install)
done
fetch $CONNTRACK
(cd $CONNTRACK; ./configure --disable-shared && make && rm -f src/conntrack && make LDFLAGS=-all-static)
copy_exe $CONNTRACK/src/conntrack
# curl
CURL=curl-7.40.0
rm -rf $CURL
curl -s -S http://curl.haxx.se/download/$CURL.tar.gz | tar xvz
(cd $CURL; ./configure --without-ssl --disable-shared && make && rm src/curl && make LDFLAGS=-all-static)
copy_exe $CURL/src/curl
#
touch "$BASEDIR"/bin
+105 -69
View File
@@ -2,6 +2,15 @@
set -e
SCRIPT_VERSION="(unreleased version)"
DOCKERHUB_USER=zettio
if [ "$SCRIPT_VERSION" = "(unreleased version)" ] ; then
IMAGE_VERSION=latest
else
IMAGE_VERSION=$SCRIPT_VERSION
fi
IMAGE_VERSION=${VERSION:-$IMAGE_VERSION}
usage() {
echo "Usage:"
@@ -27,27 +36,49 @@ usage() {
exit 1
}
[ $(id -u) = 0 ] || {
echo "weave must be run as 'root'" >&2
[ $# -gt 0 ] || usage
# These are potentially used for remote execs, and have defaults, so
# we introduce them here
DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0}
PROCFS=${PROCFS:-/proc}
BASE_IMAGE=$DOCKERHUB_USER/weave
BASE_DNS_IMAGE=$DOCKERHUB_USER/weavedns
BASE_EXEC_IMAGE=$DOCKERHUB_USER/weaveexec
IMAGE=$BASE_IMAGE:$IMAGE_VERSION
DNS_IMAGE=$BASE_DNS_IMAGE:$IMAGE_VERSION
EXEC_IMAGE=$BASE_EXEC_IMAGE:$IMAGE_VERSION
exec_remote() {
docker run -t --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$PROCFS":/hostproc \
-e VERSION \
-e WEAVE_DOCKER_ARGS \
-e WEAVE_PASSWORD \
-e DOCKER_BRIDGE \
-e PROCFS=/hostproc --privileged --net=host \
$EXEC_IMAGE --local "$@"
}
# "run" is a special case because we want to use docker directly,
# rather than the docker in $EXEC_IMAGE remotely. That's because we
# are passing arbitrary arguments on to docker run, and we can't rely
# on our baked-in docker to support those arguments.
if [ "$1" = "--local" ]; then
LOCAL="$1"
shift 1
elif [ "$1" != "run" ]; then
exec_remote "$@"
exit $?
fi
[ $(id -u) = 0 ] || ([ "$1" = "run" ] && [ -z "$LOCAL" ]) || {
echo "weave must be run as 'root' when run locally" >&2
exit 1
}
[ $# -gt 0 ] || usage
if [ "$SCRIPT_VERSION" = "(unreleased version)" ] ; then
IMAGE_VERSION=latest
else
IMAGE_VERSION=$SCRIPT_VERSION
fi
IMAGE_VERSION=${VERSION:-$IMAGE_VERSION}
BASE_IMAGE=zettio/weave
BASE_DNS_IMAGE=zettio/weavedns
BASE_TOOLS_IMAGE=zettio/weavetools
IMAGE=$BASE_IMAGE:$IMAGE_VERSION
DNS_IMAGE=$BASE_DNS_IMAGE:$IMAGE_VERSION
TOOLS_IMAGE=$BASE_TOOLS_IMAGE:$IMAGE_VERSION
CONTAINER_NAME=weave
DNS_CONTAINER_NAME=weavedns
BRIDGE=weave
@@ -56,26 +87,42 @@ MTU=65535
PORT=6783
HTTP_PORT=6784
DNS_HTTP_PORT=6785
DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0}
PROCFS=${PROCFS:-/proc}
COMMAND=$1
shift 1
dns_args() {
if [ "$1" = "--with-dns" ] ; then
shift 1
if [ \( "$DOCKER_VERSION_MAJOR" -lt 1 \) -o \
\( "$DOCKER_VERSION_MAJOR" -eq 1 -a \
"$DOCKER_VERSION_MINOR" -lt 2 \) ] ; then
echo "ERROR: The '--with-dns' option requires Docker 1.2.0 or later; you are running $DOCKER_VERSION" >&2
exit 1
fi
docker_bridge_ip
DNS_ARG="--dns $DOCKER_BRIDGE_IP"
DNS_SEARCH_ARG="--dns-search=."
for arg in "$@"; do
case $arg in
--dns-search=*)
DNS_SEARCH_ARG=""
;;
*)
;;
esac;
done
fi
DNS_ARGS="$DNS_ARG $DNS_SEARCH_ARG"
}
# utility function to check whether a command can be executed by the shell
# see http://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script
command_exists () {
command -v $1 >/dev/null 2>&1
}
run_tool() {
TOOL_NET=$1
TOOL_COMMAND=$2
shift 2
docker run --rm -t --privileged --net=$TOOL_NET $TOOLS_IMAGE /bin/$TOOL_COMMAND "$@"
}
is_cidr() {
# The regexp here is far from precise, but good enough.
echo "$1" | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}$' >/dev/null
@@ -164,11 +211,7 @@ create_bridge() {
add_iptables_rule nat POSTROUTING -j WEAVE
}
if [ ! "$1" = "--without-ethtool" ] ; then
# disable offloading - we do this even when $BRIDGE already exists
# simply because it has the desirable side-effect of ensuring we
# have the $TOOLS_IMAGE and thus do not incur downloading-induced
# delays in more time-sensitive sections elsewhere.
run_tool host ethtool -K $BRIDGE tx off >/dev/null
ethtool -K $BRIDGE tx off >/dev/null
fi
ip link set dev $BRIDGE up
@@ -253,7 +296,7 @@ connect_container_to_bridge() {
return 1
fi
if ! run_tool host ethtool -K $GUEST_IFNAME tx off >/dev/null ||
if ! ethtool -K $GUEST_IFNAME tx off >/dev/null ||
! ip link set $LOCAL_IFNAME master $BRIDGE ||
! ip link set $LOCAL_IFNAME up ||
! ip link set $GUEST_IFNAME netns $NETNS ; then
@@ -275,7 +318,7 @@ launch() {
return 1
fi
connect_container_to_bridge &&
run_tool container:$CONTAINER ethtool -K eth0 tx off >/dev/null &&
ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null &&
ip netns exec $NETNS ip link set $CONTAINER_IFNAME up
}
@@ -357,7 +400,7 @@ http_call_ip() {
http_verb="$3"
url="$4"
shift 4
run_tool host curl -s -X $http_verb "$@" http://$ip:$port$url
curl -s -X $http_verb "$@" http://$ip:$port$url
}
# Perform operation $1 on container ID $2 to local DNS database at address $3
@@ -483,7 +526,7 @@ DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
case "$COMMAND" in
setup)
for img in $IMAGE $DNS_IMAGE $TOOLS_IMAGE ; do
for img in $IMAGE $DNS_IMAGE $EXEC_IMAGE ; do
docker pull $img
done
;;
@@ -574,49 +617,42 @@ case "$COMMAND" in
echo weave script $SCRIPT_VERSION
ask_version $CONTAINER_NAME $IMAGE
ask_version $DNS_CONTAINER_NAME $DNS_IMAGE
if ! TOOLS_IMAGE_ID=$(docker inspect --format='{{.Id}}' $TOOLS_IMAGE 2>/dev/null) ; then
echo "Unable to find $TOOLS_IMAGE image." >&2
if ! EXEC_IMAGE_ID=$(docker inspect --format='{{.Id}}' $EXEC_IMAGE 2>/dev/null) ; then
echo "Unable to find $EXEC_IMAGE image." >&2
else
TOOLS_VERSION=$(docker images --no-trunc | grep $TOOLS_IMAGE_ID | grep -v latest | tr -s ' ' | cut -d ' ' -f 2 | tr "\n" ' ')
if [ -n "$TOOLS_VERSION" ] ; then
echo "weave tools $TOOLS_VERSION"
EXEC_VERSION=$(docker images --no-trunc | grep $EXEC_IMAGE_ID | grep -v latest | tr -s ' ' | cut -d ' ' -f 2 | tr "\n" ' ')
if [ -n "$EXEC_VERSION" ] ; then
echo "weave exec $EXEC_VERSION"
else
echo "weave tools (unreleased version)"
echo "weave exec (unreleased version)"
fi
fi
;;
run)
[ $# -gt 0 ] || usage
if [ "$1" = "--with-dns" ] ; then
shift 1
if [ \( "$DOCKER_VERSION_MAJOR" -lt 1 \) -o \
\( "$DOCKER_VERSION_MAJOR" -eq 1 -a \
"$DOCKER_VERSION_MINOR" -lt 2 \) ] ; then
echo "ERROR: The '--with-dns' option requires Docker 1.2.0 or later; you are running $DOCKER_VERSION" >&2
exit 1
fi
docker_bridge_ip
DNS_ARG="--dns $DOCKER_BRIDGE_IP"
DNS_SEARCH_ARG="--dns-search=."
for arg in "$@"; do
case $arg in
--dns-search=*)
DNS_SEARCH_ARG=""
;;
*)
;;
esac;
done
if [ "$LOCAL" = "--local" ]; then
dns_args "$@"
else
DNS_ARGS=$(exec_remote dns-args "$@")
[ "$1" = "--with-dns" ] && shift 1
fi
CIDR=$1
validate_cidr $CIDR
shift 1
create_bridge
CONTAINER=$(docker run $DNS_ARG $DNS_SEARCH_ARG -d "$@")
with_container_netns $CONTAINER attach $CIDR >/dev/null
tell_dns PUT $CONTAINER $CIDR
validate_cidr $CIDR
CONTAINER=$(docker run $DNS_ARGS -d "$@")
if [ "$LOCAL" = "--local" ]; then
create_bridge
with_container_netns $CONTAINER attach $CIDR >/dev/null
tell_dns PUT $CONTAINER $CIDR
else
exec_remote attach $CIDR $CONTAINER
fi
echo $CONTAINER
;;
dns-args)
dns_args "$@"
echo -n $DNS_ARGS
;;
start)
[ $# -eq 2 ] || usage
CIDR=$1
@@ -673,7 +709,7 @@ case "$COMMAND" in
echo "Weave is not running." >&2
fi
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
run_tool host conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
;;
stop-dns)
[ $# -eq 0 ] || usage
@@ -688,7 +724,7 @@ case "$COMMAND" in
docker kill $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
docker rm -f $CONTAINER_NAME >/dev/null 2>&1 || true
docker rm -f $DNS_CONTAINER_NAME >/dev/null 2>&1 || true
run_tool host conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
destroy_bridge
for LOCAL_IFNAME in $(ip link show | grep v${CONTAINER_IFNAME}pl | cut -d ' ' -f 2 | tr -d ':') ; do
ip link del $LOCAL_IFNAME
+8
View File
@@ -0,0 +1,8 @@
FROM gliderlabs/alpine
MAINTAINER Weaveworks Inc <help@weave.works>
WORKDIR /home/weave
RUN ["apk", "add", "--update", "ethtool", "conntrack-tools", "curl", "iptables", "iproute2"]
RUN ["sh", "-c", "rm -rf /var/cache/apk/*"]
ADD ./weave /home/weave/
ADD ./docker.tgz /
ENTRYPOINT ["/home/weave/weave"]