Docker on Raspberry Pi | How to
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.
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.