How I setup a Raspberry Pi 3 Cluster Using The New Docker Swarm Mode In 29 Minutes

Image for post
Image for post

Helllooooo, everyone! I know it’s been a little while since I wrote about anything on here. I’ve been on vacation from work for the past week, and finally had the time to mess around with a couple of things I’ve wanted to work on for a while! Today I want to tell you about my journey to deploy a cluster management solution to four Raspberry Pi 3’s I had sitting around my apartment. If you have been hiding under a rock for the past year or two, open-source cluster management has become a huge thing in the tech world allowing teams to provide efficient resource isolation and sharing across distributed applications/frameworks. At work, I have been playing with Mesos (and Marathon) for a number of projects, so I took this as an opportunity, at first, to try out Kubernetes. There are a large number of great blog posts out there detailing how others managed to bring up their clusters from scratch. In particular, I looked at the following posts/projects:


Each solution is well documented and simple to follow, but I came across problems, most likely because I was attempting to use up-to-date hardware/software and NOT the old locked versions mentioned in the blog posts. Anyone who has played with these bleeding edge technologies knows that things can change drastically in a week, let alone a year. I wanted to use my RPi3’s (not the Raspberry Pi 2), and Hypriot v0.8.0 Barbossa (so many excellent new features and updated core packages). Also, Hypriot v0.8.0 Barbossa running on a Raspberry Pi 3 seems to be an incredibly powerful combination according to the community, and I did not want to miss out on any of that especially when I only have a week to hack on things before being swamped at work again. At some point, I touched base with @Quintus23M AKA Dieter Reuter (Docker Pirate at @HypriotTweets) and he told me about some of the magic the lovely people have been cooking up over at Docker with v1.12.0. The following is my experience setting up my cluster with the new Docker Swarm Mode!

My setup: Hardware

In case you want to follow my exact steps, here is my exact setup:

Image for post
Image for post

5:36pm EDT: Preparation Step — Flash Micro SD Cards With Hypriot v0.8.0

First things first, I needed to download the Hypriot v0.8.0 image. Since I’m using OS X, I was able to leverage the Flash CLI tool developed by the Hypriot team ( This little guy takes care of image customization very efficiently before the Raspberry Pi is even turned on. Here you can predefine a proper hostname, WIFI settings, and more. On top of that, it has error handling built into it, handles unmounting the SD card for writing, and prompts you when everything is done. Must have tool. For each SD card, I ran the command below with the following host names, scarlett-kub-master, scarlett-kub-slave1, scarlett-kub-slave2, scarlett-kub-slave3. (NOTE: Hostnames remain the same as when I was working on k8s).

Ready to go!

5:45pm EDT: Preparation Step — Set Up Password-less SSH Access

When dealing w/ multiple nodes and SSH Access, using SSH keys to connect to remote machines is a must. You do not want to have to type in your password every single time you interact with one of your remote servers; that’s madness. To set up passwordless authentication I did the following (NOTE: This assumes that you have a private key created already; if you don’t, see this guide on how to get setup

A. First, you need to obtain the IP addresses of each of the Raspberry Pi’s running on your LAN. If you’re savvy on the command line, you can use something like arp-scan. If you prefer a GUI, try LanScan Pro. I used Hypriot’s custom bash function to do a lookup against the Avahi-daemon configured on each Raspberry Pi:

B. Now to test that everything works, I ran:


5:47pm EDT: (Optional) Set up SSH Autocomplete

A. Open up ~/.ssh/config and add an entry that looks like the following:

B. Add this line to your ~/.bash_profile then run source ~/.bash_profile:

C. Reload your shell, type scarlett-kub-[TAB] and it should work. Repeat for each of the other RPi’s.

5:50pm EDT: Installation Of Docker 1.12.0-rc3 On Each Node

As of today, 7/8/2016 Docker 1.12.0 is a release candidate, rc3 to be exact. Luckily, @Quintus23M was able to hook me up with a custom compiled .deb package built from upstream! Here were the steps to install it:

A. Grab the binary then scp it to each machine:

B. Remove the old docker-hypriot that is currently installed, and install rc3 (Repeat for each machine):

C. SSH to machine, run docker version and you should see something like this:

Image for post
Image for post


5:56pm EDT: Bootstrap The Master!

Believe it or not, this only takes one command. Run the following:

Yes …. That’s it. Verify that everything worked by running the following ( ssh to master node first ):


5:58pm EDT: Time To Bootstrap Some Nodes!

Just when you thought it couldn’t get any easier… Run this from OS X( NOTE: Assume bash variable $MASTER is the ip address of your master node):

BOOM. Run that verification command again and you should see something like this:

Image for post
Image for post

Can’t believe it yet? Well, we are not done yet! Time to bring up some containers.

6:00pm EDT: Let’s bring up a container that simply pings google’s DNS server:


6:02pm EDT: Scale up the number of tasks running! How about 10 of these bad boys? No problem, let’s run this:

Andddd, we’re done.

Image for post
Image for post

6:05pm EDT: Sit Back In Awe.

It’s that simple. Bravo to Hypriot and Docker. You guys just made my whole week! The craziest part is, this is my first time using HypriotOS and Docker together! 29Minutes start-to-finish. Madness.

Thanks for following the journey, please don’t hesitate to contact me or drop a comment if this was useful for you!

Further reading:


2. (In general)

3. Read up more about Docker Swarm Mode coming out in 1.12.0 here:

Written by

TONY DARK. Black Tony Stark. DevOps Engineer @Behance (acq’d by @Adobe). NUPE, WAHOO. Commonly referred to as #heron, SON OF BABYLON, Le #Hyena. I build shit.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store