From 51afd5e9c6f1b357729d227034d322b539ed0b54 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 11 Sep 2014 07:56:26 +0100 Subject: [PATCH] make 'weave launch' cope gracefully with existing 'weave' containers Fixed #31 --- weaver/weave | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/weaver/weave b/weaver/weave index 76fb260d..5dab5d9b 100755 --- a/weaver/weave +++ b/weaver/weave @@ -82,6 +82,23 @@ case "$COMMAND" in # (eth0, wlan0, etc) so the name becomes stable across host # restarts. MACADDR=`cat /sys/class/net/$BRIDGE/address` + case $(docker inspect --format '{{ .State.Running }} {{ .Config.Image }}' weave 2>/dev/null) in + "true zettio/weave") + echo "Weave is already running." >&2 + exit 1 + ;; + "false zettio/weave") + docker rm weave >/dev/null + ;; + true*) + echo "Found another running container named 'weave'. Aborting." >&2 + exit 1 + ;; + false*) + echo "Found another container named 'weave'. Aborting." >&2 + exit 1 + ;; + esac CONTAINER=$(docker run --privileged -d --name=weave -p 6783:6783/tcp -p 6783:6783/udp $WEAVE_DOCKER_ARGS zettio/weave -name $MACADDR "$@") echo $CONTAINER IFACE=eth0