Skip to content

Commit

Permalink
Merge pull request #574 from weaveworks/560-work-with-1.2
Browse files Browse the repository at this point in the history
Make scope work with weave master.
  • Loading branch information
tomwilkie committed Oct 20, 2015
2 parents b06b13d + b77fbcd commit 4cc9a13
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ DOMAIN=weave.local
IP_REGEXP="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"

container_ip() {
if ! status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' $1 2>/dev/null); then
echo "$2" >&2
if ! status=$(docker inspect --format='{{.State.Running}} {{.HostConfig.NetworkMode}}' $1 2>/dev/null); then
echo "Container $1 not found" >&2
return 1
fi
case "$status" in
"true ")
echo "$1 container has no IP address; is Docker networking enabled?" >&2
return 1
"true host")
CONTAINER_IP="127.0.0.1"
return 0
;;
true*)
CONTAINER_IP="${status#true }"
"true default" | "true bridge")
CONTAINER_IP="$(docker inspect --format='{{.NetworkSettings.IPAddress}}' $1 2>/dev/null)"
return 0
;;
*)
echo "$3" >&2
echo "Container $1 not running" >&2
return 1
;;
esac
Expand All @@ -44,11 +45,22 @@ docker_bridge_ip() {
echo ${DOCKER_BRIDGE_IP#inet }
}

# Run `weave` in the weave exec container
weave() {
WEAVEXEC_IMAGE=$(docker inspect --format='{{.Config.Image}}' weave | sed 's/\/weave/\/weaveexec/')
docker run -t --rm --privileged --net=host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /proc:/hostproc \
-e PROCFS=/hostproc \
$WEAVEXEC_IMAGE --local "$@"
}

# Run `weave expose` if it's not already exposed.
weave_expose() {
status=$(weave --local ps weave:expose | awk '{print $3}' 2>/dev/null)
status=$(weave ps weave:expose | awk '{print $3}' 2>/dev/null)
if [ "$status" = "" ]; then
weave --local expose
echo "Exposing host to weave network."
weave expose
fi
}

Expand Down Expand Up @@ -127,7 +139,7 @@ if is_running $WEAVE_CONTAINER_NAME; then
exit 1
else
for ip in $IP_ADDRS; do
weave --local dns-add $ip $CONTAINER -h $HOSTNAME.$DOMAIN
weave dns-add $ip $CONTAINER -h $HOSTNAME.$DOMAIN
done
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion integration/320_container_edge_cross_host_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ scope_on $HOST2 launch

weave_on $HOST1 run -d --name nginx nginx
weave_on $HOST2 run -d --name client alpine /bin/sh -c "while true; do \
wget http://nginx.weave.local:80/ >/dev/null || true; \
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
sleep 1; \
done"

Expand Down

0 comments on commit 4cc9a13

Please sign in to comment.