Running API Builder on Raspberry Pi Cluster using Docker Swarm – Part 1

Raspberry Pi Cluster

A cluster is a group of computers performing the same task, operating as a single system. Although Raspberry Pi’s are pretty incredible devices, a single Pi can only do so much.

A Raspberry Pi cluster can be used anytime you want to improve performance or availability, and there are many use cases including serving web content, mining cryptocurrency, processing large amounts of data (using tools like hadoop), and running API Builder cluster on Swarm.

I will be sharing a series of blog posts that will first give an overview of what I’m trying to build, next the details to get API Builder running on Raspberry Pi, and finally running as a cluster on Docker Swarm.

Pi Cluster Hardware

To build the Pi cluster, I will use a PicoCluster 5 node kit that includes the following components:

  • 5 Raspberry Pi 3
  • Internal 50 watt power supply
  • 8 port gigabit switch
  • 5 32GB SD cards – preloaded with operating system and Docker Swarm
  • 5 Blinkt! LED

Here’s a photo of the assembled PicoCluster.

Docker Swarm Setup

Good news! Docker and initial Swarm are preconfigured on the OS image. The nice people at PicoCluster even provided some simple scripts to start a Swarm visualizer. All that remains to setup Docker and Swarm is to launch the visualizer services. The following command shows how this is done:

sudo docker service create \
        --name viz \
        --publish 8080:8080/tcp \
        --constraint node.role==manager \
        --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \

 This command will create a swarm service and will only run the alexellis2/visualizer-arm:latest image on the manager node — in our cluster, the first Pi will be the manager.

If you open a browser and navigate to the manager node on port 8080, you will see the Swarm topology:

Next Steps

That’s all for now!  I just wanted to give little overview of what the Pi Cluster looks like and how Docker Swarm is setup. Next time, I will install a new version of API Builder v4 on the Pi, then create docker images to run as a Swarm service.

Check out Part 2 of this series here!