Portable #Docker #Swarm made of #RaspberryPI

By | July 7, 2017

This is the new cool thing to build at home. A small cluster made of Raspberry PIs.

Hardware setup of the cluster

ITEM 1: Raspberry Pi 3 Model B

I went for a set of 5 PIs because of the greater flexibility when you get more machines. I hope to be able to test several DR and HA scenarios and also have a proper Docker Swarm meeting the minimum number of a HA swarm.

ITEM 2: USB Power Hub

By chance I found a high power (12A) USB PROMATE power hub with 6 ports. This is perfect to power all the PI nodes and has an additional port for an optional portable WIFI router.

ITEM 3: USB power cables

This set of short 30cm cables was also found by chance. They are very cheap (6 EUR in total) and they look good.

ITEM 4: Micro SD cards

This is a set of HAMA 16GB micro SD cards the cheapest and smallest I could find.

ITEM 5: Raspberry cases

This is very nice set of cases made of several layers of plastic. Great looking and very strong and around 25EUR for all 5.
The hard part was to peal the protection layer to make them transparent.

Because I want the cluster to be portable I am going to use WIFI only for networking. So no extra network cables and I reuse my old portable Edimax micro router powered by the same USB power hub as the PIs.

Software setup

STEP 1: Download PI light


Flash the .img file to the MicroSD cards.

STEP 3: Enable wifi networking at boot

Mount the SD card and create under boot a file “wpa_supplicant.conf” with content

Do this for all the SD cards.

STEP 4: Enable ssh

Mount the SD cards and create under boot an empty file called “ssh”
Do this for all the SD cards.

STEP 5: Start the PIs
Insert the SD cards in all the PI nodes and power up the USB hub.
Wait for the PIs to boot and then connect to the WIFI router to see what IPs were given to them.

STEP 6: Change hostname of PI nodes


STEP 7: Change passwords

Change pi and root users passwords.

STEP 8: Install Docker
Sadly installing using apt-get will install an older version so we are going to install using the docker alternative installer.

STEP 9: Create the docker swarm

Note that in the last versions of docker it is required to specify “–advertise-addr” when joining the swarm. In the above “node_ip” is the real IP of the node of the swarm, that is visible from the master.

STEP 10: Add the nodes to the Docker Swarm
Add another two nodes as master nodes to the Docker Swarm and the remaining two as worker nodes.

STEP 11: List the swarm nodes

STEP 12: Next install docker-compose

Execute on all the 5 nodes:

STEP 13: Monitor the Swarm with Portainer

Install Portainer as a service to be able to monitor the swarm.

Now we have a portable 5 node Docker Swarm on Raspberry PIs ready for testing.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.