Docker Swarm

Current versions of the Docker Engine include swarm mode for natively managing a cluster of Docker Engines, called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.

Docker Cloud provides a hosted registry service with build and testing facilities for Dockerized application images; tools to help you set up and manage host infrastructure; and application lifecycle features to automate deploying (and redeploying) services created from images.

This tutorial outlines how to turn your BigBoards device in a Docker Swarm and manage it from anywhere in the world from your local Docker Engine via Docker Cloud.


To complete the tutorial, there are some prerequisites:

  1. Do a factory reset of your device.
  2. Install Docker on all nodes
    1. bb run 'apt-get remove docker docker-engine'
    2. bb run 'apt-get update'
    3. bb run 'apt-get -y upgrade'
    4. bb run 'apt-get -y autoremove'
    5. bb run 'apt-get -y install linux-image-extra-$(uname -r) linux-image-extra-virtual'
    6. bb run 'apt-get -y install apt-transport-https ca-certificates curl software-properties-common'
    7. bb run 'curl -fsSL | sudo apt-key add -'
    8. bb run 'add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"'
    9. bb run 'apt-get -y update'
    10. bb run 'apt-get -y install docker-ce'
    11. bb run 'docker run hello-world'

Build a swarm

The next step is to turn your BigBoards device in a Docker Swarm.

How to do this is explained in Docker's Swarm tutorial, but here is the rundown:

  1. Log in to your device's 1st node, the manager node
  2. Initialize the swarm manager
    1. Note the IP address of the manager node; you can use the internal IP
    2. docker swarm init --advertise-addr <MANAGER-IP>
    3. Copy the command to join the swarm as it is printed by the init command
  3. Join the other nodes to the swarm
    1. ansible host-workers --sudo -m shell -a '<COMMAND-TO-JOIN>'
  4. Check the status of the swarm
    1. docker info gives you an overview of the swarm
    2. docker node ls lists all nodes in the swarm, e.g.
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
pjtfg2sxm914w616bufmh9tqq *   jill-n1             Ready               Active              Leader
jgqr12mnpxf91lk1fj4eihudf     jill-n2             Ready               Active
c8tqqhjhrr0ng4bwbx8joxf3o     jill-n3             Ready               Active

From the Docker Cloud, you can manage your Docker Swarm cluster. We first need to link your swarm to the cloud.

  1. Create an account on Docker Cloud and log in.
  2. Link your swarm
    1. From the top menu, go to Swarms (Beta)
    2. Click Bring your own swarm
    3. Run the commands presented to you and name your swarm
    4. Make sure your router/firewall forwards port 2376 to your masternode
  3. On your personal computer, connect to your swarm through Docker Cloud
    1. Follow the instruction in the tutorial Connect to swarm through Docker Cloud
    2. Listing the nodes docker node ls should give the same result as above
  4. Finally, test your swarm by Deploying a service to the swarm

Wrap up

So, that's it! In this tutorial you learned:

  1. How to turn your BigBards device into a Docker Swarm cluster
  2. How to link your BigBoards swarm to Docker Cloud

With this a setup, you have a 3 or 6 node swarm, which you can completely manage from the Docker Engine running on your Personal Computer.


To undo the swarming of you BigBoards device, follow these steps:

  1. Remove all running services
    1. List running services docker service ls
    2. Remove running services docker service rm <SERVICE>
  2. Disconnect your local Docker Engine from your swarm
    1. unset DOCKER_HOST
  3. Remove your swarm from Docker Cloud
    1. Go to Docker Cloud
    2. Log in
    3. Go to Swarms (Beta)
    4. Find the target swarm in the list
    5. Use the ⠇ drop down menu
    6. Unregister the swarm
  4. Log in to the devices 1st node
  5. End running services
    1. docker service ls
    2. docker service rm 'dockercloud-server-proxy'
  6. Unswarm the nodes of your BigBoards device
    1. List the nodes in the swarm docker node ls
    2. Remove the workers ansible host-workers --sudo -m shell -a 'docker swarm leave'
    3. Verify workers have left docker node ls should indicate status Down
    4. Have the master node leave the swarm docker swarm leave -f which will also erase all cluster state!