The Hotel Hero

Notes by a Sysadmin

Cluster | Philosophy | Stack

Install Docker Swarm

April 10, 2021 | Cluster

Now, I came to Swarm after have been in the K8s universe for a year or so. And I just fell in love with Docker Swarm from first try. So, I would encurage anyone working with Pi's to choose Docker Swarm over any K8s solution out there, any day under any circumstances!

The first think and most complicated is to install Docker. Do not install from snap which is not maintained any longer. Follow the instructions from Docker (or the steps below): 

This command:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release

add the official repository GPG-key:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

and for arm64bit arch:

echo \
  "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

and last:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli

Test everything by deploying a container:

sudo docker run hello-world

and make sure every thing is running as it should.

To prevent using "sudo" infront of every command, we will make a docker group and add our user:

sudo groupadd docker


sudo usermod -aG docker $USER

After the above you have to log out of the session and in again.

Setting up Swarm

Start by initialising Swarm on the "manager" node:

docker swarm init --advertise-addr (manager ip)

after that you will get a command with a token, that you have to run on all nodes (agents/slaves) that you want to connect to the master (cluster). Important: You have to install docker on those machines too.

Command ex.:

docker swarm join --token SWMTKN-1-3k26e5jjbr6pgha59wt7xo5nsdcyjlgw6hu0fcl4ons8-cwvdge26mywxi5nh70q1lbwu2

After all nodes are connected, run the following command to check that the master has connection:

docker node ls

You should see something like this:


I'm a Sysadmin, network manager and cyber security entusiast. The main purpose of this public "notebook" is for referencing repetitive tasks, but it might as well come in handy to others. Windows can not be supported! But all other OS compliant with the POSIX-standard can (with minor adjustments) apply the configs on the site. It is Mac OSX, RHEL and all the Fedora based distros and Debian based (several 100's of OS's), all the BSD distros, Solaris, AIX and HP-UX.