Part 3: Creating and Scaling Multi-host Docker Deployment with Swarm and Compose using Weave

In this Part 3 of the guide you will be introduced to using Weave Net with Docker Swarm and Docker Compose.

Docker Machine makes it really easy to create Docker hosts (VMs) on your computer, on cloud providers and inside your own data center. It creates servers, installs Docker on them, and configures the Docker client to talk to them.

Docker Swarm is Docker’s native clustering environment. It turns a pool of Docker hosts into a single, virtual host. You can instruct Docker Machine to provision a Swarm cluster for you, and then integrate the Swarm using Weave Net. Both of these concepts were explored in Part 1 and Part 2.

With Docker Compose you can define and run complex applications with Docker.
Compose is an extra layer that allows you to combine a multi-container application into a single file and then launch your application with a single command.

What You Will Use

If you are already familiar with Compose, then you will recognize the Flask app used here. If you haven’t yet used Compose, then have a look at the overview in Docker Compose Documentation which describes the app and the docker-compose.yml file structure, as well as the Dockerfile used.

Before You Begin

If you are using OS X, then install Docker Toolbox, which provides the tools you need.

For all other operating systems, install and configure the following separately before proceeding:

Provisioning the VMs

1. Automating the Set up

If you didn’t continue from Part 2, run the following commands to create the 3 VMs with a Weave network. If you chose to destroy all the VMs in Part 2, then you’ll need to run through these commands again.

> curl 192.168.99.129
Hello World! I have been seen 4 times.
> curl 192.168.99.130
Hello World! I have been seen 5 times.

You have just deployed and scaled a simple app using Weave Net, Swarm and Compose!

4. Deploying Clusters to Public Clouds

Deploy a cluster to the public cloud by setting the
DOCKER_MACHINE_DRIVER variable and also by specifying the required provider-specific environment variables before running the ./1-machine-create.sh shell script. But before you do so, make sure that you remove the VirtualBox VMs first.

For example, if you are using Microsoft Azure, then set the following variables:

Note: that this guide is open-source, and if you would
like to expand this guide to cover other clould providers in detail, please feel free to submit a pull-request to our guides
repository.

Cleanup

You can tear-down the VMs you have deployed:

docker-machine rm -f weave-1 weave-2 weave-3

Summary

In this final Part 3 of “Creating and Scaling Multi-host Docker Deployment with Swarm and Compose using Weave tutorial you have looked
at how Weave Net works with all three components of the Docker platform (Machine, Swarm & Compose). You should now be able to understand all that is required in setting up a scalable cluster of Docker hosts using Weave Net.

You may automate your deployment somewhat differently, and for this reason, this tutorial is split into three parts with each part describing the necessary concepts so that you can understand how Weave Net helps you deploy and manage your applications.