From 7f65530b2654ccc7dd05258029d867b218d148e0 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 10 Nov 2015 15:59:11 +0000 Subject: [PATCH 1/5] `weave setup` fetches plugin --- weave | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weave b/weave index 80bcd57a..49456ef3 100755 --- a/weave +++ b/weave @@ -288,6 +288,9 @@ fi BASE_IMAGE=$DOCKERHUB_USER/weave IMAGE=$BASE_IMAGE:$IMAGE_VERSION +BASE_PLUGIN_IMAGE=$DOCKERHUB_USER/plugin +PLUGIN_IMAGE=$BASE_PLUGIN_IMAGE:$IMAGE_VERSION + PROCFS=${PROCFS:-/proc} DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0} CONTAINER_NAME=${WEAVE_CONTAINER_NAME:-weave} @@ -1653,7 +1656,7 @@ shift 1 case "$COMMAND" in setup) - for img in $IMAGE $EXEC_IMAGE ; do + for img in $IMAGE $EXEC_IMAGE $PLUGIN_IMAGE ; do docker pull $img done ;; From b21afcb78f43da49ed2361c01c1575b68a2aee66 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 10 Nov 2015 16:42:58 +0000 Subject: [PATCH 2/5] Implement `weave launch-plugin` and `weave stop-plugin` --- weave | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/weave b/weave index 49456ef3..5acd9edc 100755 --- a/weave +++ b/weave @@ -58,6 +58,7 @@ weave launch-proxy [-H ] [--with-dns | --without-dns] [--hostname-match ] [--hostname-replacement ] [--rewrite-inspect] +weave launch-plugin weave env [--restore] weave config weave connect [--replace] [ ...] @@ -80,6 +81,7 @@ weave ps [ ...] weave stop weave stop-router weave stop-proxy +weave stop-plugin weave reset weave rmpeer @@ -290,6 +292,7 @@ IMAGE=$BASE_IMAGE:$IMAGE_VERSION BASE_PLUGIN_IMAGE=$DOCKERHUB_USER/plugin PLUGIN_IMAGE=$BASE_PLUGIN_IMAGE:$IMAGE_VERSION +PLUGIN_CONTAINER_NAME=weaveplugin PROCFS=${PROCFS:-/proc} DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0} @@ -1558,6 +1561,18 @@ stop_proxy() { stop $PROXY_CONTAINER_NAME "Proxy" } +launch_plugin() { + PLUGIN_CONTAINER=$(docker run --privileged -d --name=$PLUGIN_CONTAINER_NAME \ + --net=host \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /run/docker/plugins:/run/docker/plugins \ + $PLUGIN_IMAGE "$@") +} + +stop_plugin() { + stop $PLUGIN_CONTAINER_NAME "Plugin" +} + ########################################################################################## [ $(id -u) = 0 ] || { @@ -1708,6 +1723,11 @@ EOF launch_proxy "$@" echo $PROXY_CONTAINER ;; + launch-plugin) + check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE + launch_plugin "$@" + echo $PLUGIN_CONTAINER + ;; env|proxy-env) [ "$COMMAND" = "env" ] || deprecation_warning "$COMMAND" "'weave env'" if PROXY_ADDR=$(proxy_addr) ; then @@ -1949,6 +1969,10 @@ EOF [ $# -eq 0 ] || usage stop_proxy ;; + stop-plugin) + [ $# -eq 0 ] || usage + stop_plugin + ;; reset) [ $# -eq 0 ] || usage warn_if_stopping_proxy_in_env From c345700963ec89936da4da06fc7ed09c526785ba Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 10 Nov 2015 17:28:49 +0000 Subject: [PATCH 3/5] Add plugin to `weave status` --- weave | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weave b/weave index 5acd9edc..06afef92 100755 --- a/weave +++ b/weave @@ -1783,6 +1783,11 @@ EOF echo " Service: proxy" echo " Address: $PROXY_ADDRS" fi + if [ -z "$SUB_STATUS" ] && check_running $PLUGIN_CONTAINER_NAME 2>/dev/null ; then + echo + echo " Service: plugin" + echo " DriverName: weave" + fi [ -n "$SUB_STATUS" ] || echo [ $res -eq 0 ] ;; From 04ab198e952e8811029a1686ee53b2ea3b2bd895 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 12 Nov 2015 13:07:14 +0000 Subject: [PATCH 4/5] Set restart policy to 'always' Docker attempts to recreate networks on startup which means the plugin container has to be started. If it isn't started automatically by Docker with a restart policy, it's not possible to start it manually because Docker is blocked. --- weave | 1 + 1 file changed, 1 insertion(+) diff --git a/weave b/weave index 06afef92..8e76b8fc 100755 --- a/weave +++ b/weave @@ -1563,6 +1563,7 @@ stop_proxy() { launch_plugin() { PLUGIN_CONTAINER=$(docker run --privileged -d --name=$PLUGIN_CONTAINER_NAME \ + --restart=always \ --net=host \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /run/docker/plugins:/run/docker/plugins \ From b4dd9c2490a70ed51fa1af780e8aa3fc23abdc44 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 12 Nov 2015 14:46:38 +0000 Subject: [PATCH 5/5] Add plugin to features doc --- site/features.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/site/features.md b/site/features.md index baa580a4..4dbbb7ab 100644 --- a/site/features.md +++ b/site/features.md @@ -11,6 +11,7 @@ example](https://github.com/weaveworks/weave#example): * [Virtual ethernet switch](#virtual-ethernet-switch) * [Fast data path](#fast-data-path) * [Seamless Docker integration](#docker) + * [Docker network plugin](#plugin) * [Address allocation](#addressing) * [Naming and discovery](#naming-and-discovery) * [Application isolation](#application-isolation) @@ -88,6 +89,24 @@ Containers started in this way that subsequently restart, either by an explicit `docker restart` command or by Docker restart policy, are re-attached to the weave network by the weave Docker API proxy. +### Docker network plugin + +Alternatively, you can use weave as a Docker plugin. First you must +configure the Docker daemon to use a cluster store as documented +[here](https://docs.docker.com/engine/userguide/networking/dockernetworks/#an-overlay-network); +you can then launch weave and create a network: + + $ weave launch + $ weave launch-plugin + $ docker network create --driver=weave weave + +and then start a container: + + $ docker run --net=weave -ti ubuntu + +For more details see the +[plugin README](https://github.com/weaveworks/docker-plugin). + ### Address allocation Containers are automatically allocated an IP address that is unique