Docker is a pretty useful tool to deploy our applications in containers. In this post we will cover how to install Docker, and configure it in Swarm mode on some Raspberry Pi. Also, we will use Portainer (CE), which is a web interface for managing Docker.
Requirements
These are the requierements to aproach this post:
- Raspberry Pi (x2 at least).
- As many MicroSD cards as raspberries. The size will depend on your future plans with your Pi.
- A MicroSD card reader.
- An image burner program like Raspberry Pi Imager.
- A network infrastucture to communicate the devices.
- Docker basic knowledge.
Install Raspberry with Ubuntu
To do so, I recommend to follow this guide I’ve already posted. It’s really straight forward!
Install Docker
Docker has several ways to install it, but the easiest one is by executing the get.docker.com SH file. This will install and configure all the needed packages that allows Docker to work properly. To do so:
Now you will be able to execute this:
And the output should look like this one (versions may vary):
We could also make docker to work without root permissions, but Portainer will have some troubles when managing the swarm, so we will keep it like this.
Configure Swarm
Swarm is the cluster mode of Docker, so we can deploy sevear applications with redundancy and manage how many containers of one image we want to deploy in our workers nodes. It’s very useful, but to properly work on raspberry, we need some extra modules, so the nodes can communicate between them using ports/sockets:
Once the command finished, just reboot:
Now, to start a new Swarm, we need to pick a Master. This device will be the one with the administration privileges on the Swarm, and will delivery the tasks (known as Stacks) to the Workers. Do not execute in the worker nodes!
The command above should have returned something like this:
Now, let’s copy the token and make the other nodes to join, by executing it on them (remember, the token may vary, use your own):
Now you’ll have your swarm!
Setup Portainer CE in Swarm mode
Portainer, as mentioned before, is a web interface that allows us manage Docker, even in Swarm mode. It has a Community Edition that let us use as far as five nodes in swarm. It has been packaged on a docker container, and has two different components: The manager and the agent. The manager will be deployed on our swarm manager, and the agent will be deployed on every node. To do so, we will create the services with this stack file on our swarm manager node:
Now, execute the stack with docker just in the manager:
Let’s check if the stack has been deployed:
The output should show us two containers running on the manager, and one on each worker node:
Let’s dive in on Portainer’s web interface by going to our manager’s node IP, on port 9443 with https, and it will show up the admin user creation page, fill it:

Now, the enviroment wizard, we will select the local enviroment with the Get Started option:

Once done, Portainer is all working, and should look like this:

In the future, more posts about Portainer and its functionallity will come!
Summary
We’ve covered the Ubuntu installation on Raspberry, how to download and make Docker run on them, and how to create a swarm and manage it with Portainer.
Now, we have a functional Docker swarm, on low power consumption nodes with ARM on the Pi, and we can deploy all our containers, composes and stacks with ease!