Here are the steps to deploy a simple Swarm cluster:
- install acs-engine
- generate your ssh key
- edit the Swarm example and fill in the blank strings
- generate the template
- deploy the output azuredeploy.json and azuredeploy.parameters.json
Once your Swarm cluster has been deployed you will have a resource group containing:
-
a set of 1,3, or 5 masters in a master availability set. Each master's SSH can be accessed via the public dns address at ports 2200..2204. First master's SSH can also be accessed via public dns address on port 22.
-
a set of agents in a VM scale set (VMSS). The agent VMs can be accessed through a master. See agent forwarding for an example of how to do this.
The following image shows the architecture of a container service cluster with 3 masters, and 3 agents:
All VMs are in the same VNET where the masters are on private subnet 172.16.0.0/24 and the agents are on the private subnet, 10.0.0.0/16, and fully accessible to each other.
After completing this walkthrough you will know how to:
- display information from Swarm,
- deploy a simple Docker hello-world app using docker-compose,
- and deploy a simple Docker web app publically available to the world.
-
After successfully deploying the template write down the two output master and agent FQDNs (Fully Qualified Domain Name).
-
If using Powershell or CLI, the output parameters are the last values printed.
-
If using Portal, to get the output you need to:
- navigate to "resource group"
- click on the resource group you just created
- then click on "Succeeded" under last deployment
- then click on the "Microsoft.Template"
- now you can copy the output FQDNs and sample SSH commands
-
-
SSH to port 2200 of the master FQDN. See agent forwarding for an example of how to do this.
-
Set the DOCKER_HOST environment variable to
:2375
: e.g.export DOCKER_HOST=:2375
-
Type
docker run -it hello-world
to see the hello-world test app run on one of the agents (the '-it' switches ensure output is displayed on your client) -
Now let's create a simple web app and expose to the world. Start by using your favorite linux file editor to create a file named
docker-compose.yml
with the following contents:web: image: "yeasy/simple-web" ports: - "80:80" restart: "always"
-
type
docker-compose up -d
to create the simple web server. This will take a few minutes to pull the image -
once completed, type
docker ps
to see the running image.
- in your web browser hit the AGENTFQDN endpoint (not the master FQDN) you recorded in step #1 and you should see the following page, with a counter that increases on each refresh.
- You can now scale the web application. For example, if you have 3 agents, you can type
docker-compose scale web=3
, and this will scale to the rest of your agents. Note that in this example you can only scale up to the number of agents that you have since each container requires port 80, so if you deployed a single agent, you won't be able to scale up. The Azure load balancer will automatically pick up the new containers.
Here are recommended links to learn more about Swarm, Docker, and Docker Compose:
-
Docker - learn more through Docker documentation.
-
Docker Swarm - learn more about Docker Swarm.
-
Docker Compose - Learn more about Docker Compose.