Containers over Raspberry PI with Docker, RancherOS and Portainer

Today’s computer world is experiencing a new concept of thinking apps and how to deploy them. Old application practices were focused on stacks created over a complete machine (phisical or virtual). This approach has demonstrated to lead some concerns regarding resources use, infra-application conflicts and poor development flexibility management.
Containers have born to help developers and system administrators to help in this sense. Docker has become the most known company who implemented this concept. As defined in Docker website: “A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.” (Ref.
Package software.png
But using containers alone may require advanced knowledge. For this reason a good hand is given by another company: Rancher. Rancher is “open source software that combines everything an organization needs to adopt and run containers in production. Built on Kubernetes, Rancher makes it easy for DevOps teams to test, deploy and manage their applications. Operations teams use Rancher to deploy, manage and secure every Kubernetes deployment regardless of where it is running.“.
Now, what if we try to use them togheter over a consumer grade hardware? In this article we will try it on a Raspberry PI 3 model B.

What we need

  • Raspberry PI 3 model B kit (including at least also case, USB adapater and power supply)
  • 1 micro SD card (at least 8 GB, preferrably class 10) with an SD adapter
  • 1 HDMI cable
  • a USB/wireless keyboard
  • a network cable to connect your Raspberry to your router

I remember that you can find Raspberry kits in Amazon or other e-commerce vendors many offers related to starter kits (for example give a try here) which includes part of above component. I strongly suggest to evaluate to buy a case with cooling system with fans (for example give a try here).


  • rancheros raspberry pi64 image (you can download it from here, used version v1.3.0)
  • an image flashing software like, for example, Etcher
  • a remote ssh software (like Putty if you’re working from a Windows remote PC)

Step-by-step guide

Download and install in your PC Etcher.
Download rancherOS zip file in your computer and extract .img file locally.
Run Etcher in your PC.
Click over Select Image and select RancherOS image previously downloaded. Now Etcher should also have recognised your SD card. Otherwise, click change and select correct SD card.
etcher RancherOS selected
Click on “Flash! button and wait for operation to be completed
Now you can insert SD card in your Raspberry, connect your network cable and boot it.
Login using default user “rancher” and default password “rancher”.
As warned by RancherOS installation guide, it does not currently expand the root partition to fill the remainder of the SD card automatically. Instead, the following workaround can be used to store Docker containers on a larger partition that fills the remainder.

sudo fdisk /dev/mmcblk0

when it prompts:

  • press “n” to create a new partition
  • press ENTER 4 times to accept default settings for new partition
  • press “w” to write the table and exit

an alert message will warn you that system needs a reboot in order to apply new configuration. so, let’s reboot:

sudo reboot

After reboot, re-connect to your raspberry:
create the directory to be used as the new Docker root:

sudo mkdir /mnt/docker

configure Docker to use the new root:

sudo ros config set rancher.docker.extra_args [-g,/mnt/docker]

format the disk:

sudo mkfs.ext4 /dev/mmcblk0p3

preserve this mount after reboots:

sudo ros config set mounts "[['/dev/mmcblk0p3','/mnt/docker','ext4','']]"

mount the Docker root:

sudo mount /dev/mmcblk0p3 /mnt/docker

restart Docker using the new root:

sudo system-docker restart docker

Switch to a persistent console (for example ubuntu):

sudo ros console switch ubuntu

Now docker is ready and running.
A graceful web GUI helping in managing containers is portainer. In our case, we need to install an arm compatible version:

sudo docker pull portainer/portainer:arm
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer:arm

Now you can reach your docker server with a browser, just connecting to https://<<RaspberryIpAddress>>:9000.
You will be required to set your default password for admin user, then you will be prompted to portainer GUI:
Portainer home


Final note. If you want to give a little contribute to my work, you can do it without cost and with a few seconds by clicking here. This is a shortened link forwarding, after and ads page, to my home page. This action costs nothing to you and allows me to pay at least the base costs. Moreover, you can also share this page with your friends.

If you want to know more about url shortening services and how to earn from your links, you can look my guide to Top 2019 link shortener services to earn money from your links


Please follow and like us: