Here are the steps to deploy a simple Swarm Mode cluster:
- Install acs-engine
- Generate your ssh key
- Edit the Swarm Mode example and fill in the blank strings
- Generate the template
- Deploy the output azuredeploy.json and azuredeploy.parameters.json
Once your Swarm Mode 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 Mode,
- 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 (or first master's SSH can also be accessed via public dns address on port 22.). See agent forwarding for an example of how to do this.
-
Type
docker node ls
to view the list of nodes (and their status) in the Swarm. -
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 service in a swarm and expose it to the world. Type
docker service create --name fe --publish 80:80 yeasy/simple-web
-
Once completed, type
docker service ps fe
to see the running service.
- 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 service. You can type
docker service scale fe=5
, and this will scale up the service to the desired number of replicas.
Here are recommended links to learn more about Swarm Mode, Docker, and Docker Compose:
-
Docker - learn more through Docker documentation.
-
Docker Swarm Mode - learn more about Docker Swarm Mode.