Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scope work with weave master. #574

Merged
merged 1 commit into from
Oct 20, 2015
Merged
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
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")

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

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