run the adapter
$ docker run -d --name powerstrip-weave \ --expose 80 \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave launch
launch command does the following:
- runs the weave container (by running weave launch)
- runs a container called
weavewaitso its volume can be used to access the wait-for-weave binary
- launches the HTTP adapter server
To ensure matching versions of the docker client / server - we mount the docker socket and docker binary from the host.
connect multiple hosts
If you are running multiple servers that you want to connect using weave - you pass the arguments you would normally pass to
$ docker run -d --name powerstrip-weave \ --expose 80 \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave launch 18.104.22.168 -password wEaVe
First create a powerstrip configuration:
$ mkdir -p ~/powerstrip-demo $ cat > ~/powerstrip-demo/adapters.yml <<EOF endpoints: "POST /*/containers/create": pre: [weave] "POST /*/containers/*/start": post: [weave] "POST /*/containers/*/restart": post: [weave] adapters: weave: http://weave/v1/extension EOF
And then run the powerstrip container and link it to the powerstrip-weave container:
$ docker run -d --name powerstrip \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/powerstrip-demo/adapters.yml:/etc/powerstrip/adapters.yml \ --link powerstrip-weave:weave \ -p 2375:2375 \ clusterhq/powerstrip
Now you can use the normal docker client to run containers that will connect to the weave network and wait for the network to be connected before running the job.
First you must export the
DOCKER_HOST variable to point at the powerstrip server:
$ export DOCKER_HOST=tcp://127.0.0.1:2375
You tell powerstrip-weave what IP address you want to give a container by using the
WEAVE_CIDR environment variable of a container - here we run a database server:
$ docker run -d --name mysql \ -e WEAVE_CIDR=10.255.0.1/8 \ -e MYSQL_ROOT_PASSWORD=mysecretpassword \ mysql
You can get the status of the weave network by running the
$ docker run --rm -it \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave status
You can run normal weave network commands like
$ docker run --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave expose 10.255.0.1/8
You could even run
weave run using this method although it would not wait for the weave network to be connected if you use this method.
To shutdown cleanly (i.e. close the adapter / weave and remove the wait-for-weave volume container):
$ docker run --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave stop
If you named the adapter container something different - pass the name as the first argument to the
$ docker run --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ binocarlos/powerstrip-weave stop powerstrip-weave
There is a walk-through example of running powerstrip-weave.
There is also an example of a fig stack that links 2 containers using weave IP addresses.
You must be running the docker server API >= 1.15 - you can check which you have by doing this:
$ docker version Client version: 1.5.0 Client API version: 1.17 Go version (client): go1.4.1 Git commit (client): a8a31ef OS/Arch (client): linux/amd64 Server version: 1.5.0 Server API version: 1.17 Go version (server): go1.4.1 Git commit (server): a8a31ef
The above shows a docker server version of 1.17 (so we are good)
- plan for this project
- running weave inside a container
- mounting the blocking binary in a volume
Copyright 2015 Kai Davenport & Contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.