Raspberry Pi is an inexpensive micro-computer that can behave like a standard computer in many respects. The innovative mini device can be used for a wide range of tasks - from setting up an operating system to surfing the web, to using it as a server or a media center. Discover these interesting Raspberry Pi projects to try out at home.
The mini-computer Raspberry Pi is good for more than just playing around or teaching children about hardware and programming. Users have set up web servers on Raspberry Pi, as well as cloud servers using ownCloud. It’s even possible to combine Raspberry Pi and Nextcloud, and some users have built Raspberry Pi mail servers.
Developers have also made the single-board computer their own. Web and software developers have already been using the mini-computer for a while, for example, in order to work with the Internet of Things. It seems high-time then to explore the advantages of Docker on Raspberry Pi.
What challenges are involved in combining Raspberry Pi and Docker?
Most Raspberry Pis run on the official operating system Raspberry Pi OS, which is an adaptation of the Linux distribution Debian. Since Docker has been used successfully for many scenarios on Linux, using it with Raspberry Pi shouldn’t be a problem. However, the differences in the hardware can indeed lead to some problems, as Pi is not just a no-frills version of a PC but uses an entirely different processor architecture.
The operating system Raspberry Pi OS was previously known under the name Raspbian.
Docker is actually based on a x64 system, which is used on most modern computers. But Raspberry Pi uses ARM technology, meaning that normal Docker images aren’t compatible with the instance on Pi. That being said, a growing number of pre-made containers are now available for Raspberry Pi. It’s of the utmost importance that users only download pre-made containers from trustworthy sources in order to avoid unnecessary security risks. Even though there haven’t been a lot of options so far (and, compared with Docker on other systems, there probably won’t be in the near future), you can still get full use out of the system by developing your own container.
The advantages of Docker on Raspberry Pi
If you know your way around computer hardware and Linux, Raspberry Pi is relatively easy to configure. That’s why the small PCs are also used for experiments. The same goes for Docker – the containers are self-contained and so cannot damage the actual system.
Because a Raspberry Pi is relatively affordable to purchase and run, the mini-computers are also a good choice for building a Docker swarm. Instead of constructing a server structure, you can simply get multiple Raspberry Pis and connect them all with one another. Then each device executes its own container. The containers can then be orchestrated with Swarm und Compose.
Small single-board computers like Raspberry Pi are being used more and more often in the context of the Internet of Things thanks to their small size and low costs. When combining Docker and Raspberry Pi you can even get container technology to run on a device that wouldn’t usually be recognized as a computer.
How to install Docker on Raspberry Pi
In the best case scenario, Docker can be installed with Raspberry Pi’s operating system. The Docker team has provided a special installation script for this. The first step involves downloading and executing the script, which you can do using a cURL command.
curl -fsSL https://get.docker.com | sh
To make sure that the installation was successful, you can try out the “hello world” image.
docker run armhf/hello-world
If everything is in order, Docker should pull the image from the Internet and execute it. You should get a message from the developer. The image here isn’t the normal “Hello world” image that would run on other systems, but rather an image that was specially made for ARM processors.
Docker containers are made available by official developers as well as members of the community. To minimize security risks, you should only use containers that are actively maintained and already being used by a good number of users. In the DockerHub you can also find containers that were put together just for Raspberry Pi. The repository also offers the option of only viewing “official images” or containers from “verified publishers”.
Hypriot OS: the all-in-one solution
A small team of developers produced a special operating system for people who want to have a better experience with Docker and Raspberry Pi: Hypriot OS is specially pre-configured for using containers. The operating system is based on Debian, but is kept to a minimum making it perfectly suited to both Raspberry Pi and Docker. The Kernel is also specifically optimized for this purpose. Thanks to the lightweight structure of the system, it’s also possible to run several computers in parallel on relatively inefficient systems.
Hypriot OS is installed like other operating systems for Raspberry Pi: First prepare an SD card on another computer with the image of Hypriot. (The operating system can be downloaded for free from the official website or from GitHub.) Then insert the memory card into the Raspberry Pi. When it starts, the computer will then load from the card and run with Hypriot. Using an SSH connection, you can then access the Raspberry Pi from the other computer and use Docker on Raspberry Pi.
Regardless of how you bring together Docker and Raspberry Pi, you’ll also have to know how to work with the container software. Learn about the first steps and pick up a lot of important information about Docker in our Docker tutorial.