I will continue to refer to the OS as Raspbian because (1) that’s what they named it when first released and (2) it still says that on the operating sytem. Therefore the name has stuck and still sticks.
- Docker Raspberry Pi 4 Image
- Docker Rpi 4 Poe
- Docker Rpi 4 Touch Screen
- Docker Raspberry Pi 4 Ubuntu
- Docker Raspberry Pi 4
- Docker Rpi 4 Case
Why Docker is not working out-of-the-box on Raspberry Pi 3 & 4 Docker is a virtualization technology, made to allow applications to be independent from the underlying system. However because it is not a full-fledge virtual machine but rather a proxy to system resources leveraging on Linux kernel’s virtualization features, it does not provide. The good news is that Raspberry Pi OS does support Docker, in both the 32-bit and 64-bit variants! Read below on how to install it as well as Docker Compose. Note: This article is written for Raspberry Pi 2, 3 and 4 running Rasperry Pi OS. Older models of the board and Raspberry Pi Zero are currently not supported.
Here are the steps to install Docker and the Portainer container that provides your Docker installation with a simple, web-based dashboard.
Raspberry Pi board (Courtesy: raspberrypi.org) This is the first in a series of blogs which will take you from getting started with installing Docker on a Raspberry Pi board to running a complete. For those that are somehow not in the know - a Raspberry Pi is a single board computer that’s roughly the dimensions of a credit card. Or likea stack of 7 or 8 credit cards, with the IO ports. They’re remarkably capable devices, and the Raspberry Pi 4 is the most powerful device yet. What can Raspberry Pi handle? That was the first question that came to my mind after seeing the option of having 4GB RAM. Of course, I know Docker runs on even smaller amounts of RAM, but when we.
Update 64-bit Raspbian:
Install Docker from the Docker website:
pi account to the
docker user group so that you can execute docker commands without sudo:
Log back in and test Docker by installing and running the following container.
The container will run and tell you it was successful with additional information about Docker and its OS.
Docker Raspberry Pi 4 Image
To be honest, I haven’t tried the recommendation about running the Ubuntu container, as I don’t know if it there is an ARM Ubuntu container (there is ARM Ubuntu, however) and if it will select the right container if there is such a container.
Install the next two containers. The first is a very simple http container.
Navigate to http://localhost with Chromium and you’ll see this:
Now add the dashboard container that implements Portainer for ARM.
Navigate to http://localhost:9000/ and create an admin password for the admin account. Once that is accomplished, you’ll see something very similar to this:
You’ll note that only two containers are listed, not three. That’s because earlier I removed the “Hello World” container. Here’s a detailed listing of the containers.
To manage any of the containers, you select that container’s checkbox. That enables all of the possible action buttons at the top of the page. Finally, here’s a check of the entire system.
The engine overview is a cleaner view of what you can get from the command line. It’s also a validation that the dashboard container is seeing everything it’s supposed to see.
If you want any container to restart after a re-boot, then you need to modify the container’s restart policy. Otherwise, on reboot, no containers are running. For example
where he container ID can be found with a
docker ps from the command line. You can set restart to always from the command line with the docker run command as well.
It’s a limitation to this application I don’t like. I’m looking for something more comprehensive, or else, (shudder) I fork the application and “fix” it myself.
At the end of May 2020, the Raspberry Pi Foundation announcedRaspberry Pi OS, the new official operating system for the mini-computer that is replacing Raspbian.
The announcement also came with the news that Raspberry Pi OS is now available in a 64-bit variant, compatible with Raspberry Pi 3 and 4. This is in addition to the 32-bit variant that has been maintained since the early days.
For the first time, users of the Raspberry Pi boards can enjoy a 64-bit operating system that is officially developed and supported by the Foundation itself. This is particularly great news especially for developers, people who are self-hosting services, and just tinkerers.
The good news is that Raspberry Pi OS does support Docker, in both the 32-bit and 64-bit variants! Read below on how to install it as well as Docker Compose.
Note: This article is written for Raspberry Pi 2, 3 and 4 running Rasperry Pi OS. Older models of the board and Raspberry Pi Zero are currently not supported.
Additionally, if you are using a different distribution for your board besides the official Raspberry Pi OS, the instructions below are not guaranteed to work for you.
Choosing the right version of Raspberry Pi OS
You can download the images for Raspberry Pi OS from the official website.
Docker Rpi 4 Poe
As of writing, images for the 64-bit variant are still in beta and can be found here.
Once you have downloaded the IMG file (which is compressed, so unzip it first) you can use the Raspberry Pi Imager to write the operating system in a SD card.
As for which image to choose, Docker works on all variants and editions of Raspberry Pi OS.
32-bit vs 64-bit
The 32-bit edition of Raspberry Pi OS will run on every board, including Raspberry 2.
If you have a Raspberry Pi 3 or 4, you have the opportunity to pick the 64-bit variant too. Using a 64-bit operating system will give you better performance and it’s required to take advantage of the full amount of memory of the 8GB Raspberry Pi 4 board.
The variant you pick will affect the Docker images you’ll be able to run. We’ll look into that below.
Desktop vs Lite
As the names suggest, the Desktop edition comes with a graphical user interface and the ability to run desktop apps. The Lite edition is headless, offering only access to the command line.
Both editions of Raspberry Pi OS can run Docker.
If you plan to use your Raspberry Pi as a headless server, pick the Lite edition to save disk space and reduce memory usage (and have a smaller potential attack surface). You will be able to control the server remotely via SSH.
Installing Docker CE (Community Edition) on the Raspberry Pi OS requires running just a few commands.
Docker Rpi 4 Touch Screen
The best way to install Docker is to fetch it from the official Docker repositories, so to ensure that you’re always running the latest version.
To install Docker CE on Raspberry Pi OS, both 32-bit and 64-bit, run:
Done! At this point, we just need to run two more commands to have the Docker service started and automatically launched at boot.
Now that we have Docker running, we can test it by running the “hello world” image:
If everything is working, the command above will output something similar to:
Docker images for 32 and 64 bit ARM
On Docker Hub, the number of images for the ARM architecture used by the Raspberry Pi is growing by the day. Even though the majority of images are still only available for the x86 architecture (used by Intel and AMD CPUs, for example), the amount of ARM-compatible images is increasing steadily.
Additionally, because of the growing popularity of 64-bit ARM in certain cloud providers, it might be especially easier to find 64-bit Docker containers.
When searching for an image on Docker Hub, you can filter by operating system and architecture, where “ARM” refers to the 32-bit variant.
In the Docker ecosystem, 64-bit ARM images are called
Docker Raspberry Pi 4 Ubuntu
Likewise, 32-bit images for Raspberry Pi OS are labeled as
Using Docker Compose
Lastly, let’s look at how to add Docker Compose.
Docker Raspberry Pi 4
Docker Compose is normally installed from pre-built binaries, downloaded from the GitHub release page for the project. Sadly, those are not available for the ARM architecture.
We can however install Docker Compose from pip:
Docker Rpi 4 Case
With this, you now have a complete Raspberry Pi mini-server running Docker and ready to accept your containers.