Add detach command

This commit is contained in:
Bryan Boreham committed 2014-09-18 17:18:54 +01:00
1 parent bb629bac84
commit 4868585d6e
1 file changed
+22 -1
+22 -1
View File
@@ -6,6 +6,7 @@ usage() {
echo "weave launch <ipaddr>/<subnet> [-passwd <passwd>] <peer_host> ..."
echo "weave run <ipaddr>/<subnet> <docker run args> ..."
echo "weave attach <ipaddr>/<subnet> <container_id>"
echo "weave detach <container_id>"
echo "weave expose <ipaddr>/<subnet>"
echo "weave hide <ipaddr>/<subnet>"
echo "weave status"
@@ -102,7 +103,7 @@ stop_masquerading() {
}
# the following borrows from https://github.com/jpetazzo/pipework
configure_container_networking() {
find_container_pid() {
DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' $1)
[ "$DOCKERPID" = 0 ] && {
echo "Container $1 not running." >&2
@@ -112,6 +113,11 @@ configure_container_networking() {
echo "Container $1 unknown to Docker." >&2
exit 1
}
return 0
}
configure_container_networking() {
find_container_pid $1
NSPID=$DOCKERPID
[ ! -d /var/run/netns ] && mkdir -p /var/run/netns
@@ -154,6 +160,15 @@ configure_container_networking() {
return $EXITCODE
}
takedown_container_networking() {
find_container_pid $1
NSPID=$DOCKERPID
LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
ip link del $LOCAL_IFNAME type veth || true
}
case "$COMMAND" in
launch)
[ $# -gt 0 ] || usage
@@ -236,6 +251,12 @@ case "$COMMAND" in
shift 1
configure_container_networking $CONTAINER $IPADDR $CONTAINER_IFNAME
;;
detach)
[ $# -gt 0 ] || usage
CONTAINER=$1
shift 1
takedown_container_networking $CONTAINER
;;
expose)
[ $# -gt 0 ] || usage
IPADDR=$1