Docker Containers for Your Raspberry Pi

Compact PCs need compact apps
Martin Wimpress
May 11, 2021


Harrison Broadbent / Unsplash

Founded in 2008 with the aim of advancing computer education for all, Raspberry Pi is a cost-effective, compact computer a little larger than a credit card that can be plugged into any monitor and can process a variety of coding languages.

Marketed at anyone from experienced coders to children, Raspberry Pi has been used for a variety of clever projects, including creating Twitter bots, automating homes, and learning how to code.

Pretty cool, right? Our team here at Slim.AI applauds the many uses of Raspberry Pis and has even toyed with them in our own home server setups. However, this compact hardware is not without drawbacks. The limited hardware specs mean that disk space and memory come at a premium, and they are best for running a single application at a time. Docker containers can mitigate these obstacles by providing a convenient place from which to store and launch entire applications, but setting up a containerized app on a Raspberry Pi present its own challenges

What is Docker and How Can I Use it with Raspberry Pi?

A Docker Container is a standard unit of software that bundles up all elements of a piece of code, to ensure application transferability from one processor to another. This allows developers to isolate their application and run it within any environment.

With Raspberry Pi known for its simple configuration, many developers use them to conduct experiments. The same applies to Docker. With users able to package multiple different software types into one container, Docker containers are handy for allowing users to get creative with their code without having to worry about server configuration, library versioning, and other sys-admin–type tasks. Best of all, because everything in the container is self-contained, the application is relatively isolated from the rest of the hardware’s operating system.

Additionally, if you need to scale beyond a single machine, containers allow you to scale your experiments effortlessly. You can deploy numerous Docker containers across numerous Pis using a wide variety of tools, and even coordinate complex application ecosystems. .

Challenges of Deploying Docker with Raspberry Pi

Currently, the record for web servers running in single containers attached to a single Raspberry Pi stands at 2334. Think you can beat this record? In 2015, Docker was so interested to see who could challenge this record that they offered to pay for anyone who could beat it to attend DockerCon Europe! (Even though it’s 2021, and well past the days of that initial competition, if you find a way to beat it, don’t forget to visit our contact page and let us in on the good news!)

Although this is truly a vast amount of servers within one small piece of technology, it is important to be aware of the amount of memory and resources that a single container takes up. For this reason, it is imperative that users set quotas to limit the amount of resources that a single container can use. You can set such quotes using command-line flags that will effectively budget the amount of resources that each application can pull from the total available.

Raspberry Pi OS Architecture Challenges

In 2020, Raspberry Pi updated their operating system to use a faster 64-bit version of the ARM architecture. This replaced their previous system, Raspbian.

Although Docker works on all editions of Raspberry Pi, you will want to ensure that you select the right variant for the images you plan to run. While the 32-bit edition will run on any board, the 64-bit edition offers maximum benefits to users of Raspberry Pi 3 and 4.

The new OS also comes in a desktop version, which allows full graphic features, and a lite version, which does not require a graphical interface to work. Ultimately, the lite feature is a benefit as it can reduce the space required to store memory.

Docker Image Challenges

Docker images take up more space as you add layers to the image. However, there are some best practices that users can implement to ensure that their images do not get too bulky.

First, users can implement codes that clean up each layer of the image as they go. This must be done before each deployment of the code, before the layer gets finalized, or else the data itself isn’t removed. Through cleaning at each layer, the user can ensure that excess data is removed as they build their application file.

Additionally, it is important to minimize the number of layers altogether. By using multi-stage layers, users can debug each stage of their image without adding to the overall file size.

Docker Security Challenges

Docker security is also a tremendous challenge that Raspberry Pi users face. Because users download OpenSource software to their containers, it is critical that users be cognizant of which libraries they are using in order to avoid users with malicious intent. Users should make sure that they use trusted, secure images and identify the source of all code that they download to their own equipment.

Along with being cautious of what you deliberately download to your Docker containers, it is important to be aware of what malware you are leaving yourself open to. For this reason, it is critical that users secure their container registries. When you use a Docker Trusted Registry, you install everything behind your own firewall in order to prevent security breaches.


Connect with fellow container enthusiasts in the Slim.AI Community

With millions of developers out there trying to solve the same problems that you are, it is critical that you join a community of like-minded developers to collaborate on answers to the industry’s most challenging questions. Join us in the Slim.AI community to learn about containers and contribute your ideas.

Related Articles

5 Most Commonly Asked DockerSlim Questions

We enlisted DockerSlim expert and Slim.AI Developer Experience Engineer to dive into how container slimming works.

Primož Ajdišek

Technical Staff

5 Ways Slim Containers Save You Money

Do slim containers really save you money on your cloud bill? Are there cost advantages to smaller containers? Find out here.

Chris Tozzi

Automating DockerSlim in Your CICD Pipeline

Using GitHub Actions, you can refine container images automatically making them smaller, faster to load, and more secure by default – all without sacrificing any capabilities.

Nicolas Bohorquez

Contributor

Building Apps Using Cloud Native Buildpacks

Getting started with this innovative technique

Vince Power

Contributor

Building DockerSlim into a Jenkins Pipeline

A step by step tutorial on building DockerSlim into your CI/CD pipeline.

Clarifying the Complex: Meet Ivan Velichko, Container Dude at Slim.AI

Ivan recently joined the team at Slim.AI, and we sat down with him to learn more about the path that led him here.

Ivan Velichko

Container Dude

Container Insights: Dissecting the World's Most Popular Containers

Join Ayse Kaya in this series, as she creates her 2022 Container Report Chalk Full of Important Security Findings for Developers.

Ayse Kaya

Analytics & Strategy

Container of the Week: Python & Flask

Our weekly breakdown of a popular container

What We Discovered Analyzing the Top 100 Public Container Images

Complexity abounds in modern development

Ayse Kaya

Analytics & Strategy

2022 Public Container Report

Vulnerabilities continue to increase and developers are struggling to keep up.

Ayse Kaya

Analytics & Strategy

Containerizing Python Apps for Lambda

A tutorial on deploying AWS Lambda using containers, Python edition.

Explore and analyze a Docker container with DockerSlim X-Ray

Understanding container composition

Martin Wimpress

Community

Five Proven Ways to Debug a Container

When Things Just Are Not Working

Theofanis Despoudis

Contributor

Five Things You Should Never Ship to Production in a Container

Here is our take on five things to avoid when creating a container or shipping it to production.

Chris Tozzi

Increasing Your CI/CD Velocity with Slim Containers

We’ll explain what Slim Containers are, how they speed up the build process, and how they can improve the efficiency of your testing.

Mike Mackrory

Contributor

Integrate Testing into Your Container Pipeline

A closer look at testing within container pipelines, CI/CD, software delivery, and containerization.

Faith Kilonzi

Software Engineer

Reducing Docker Image Size - Slimming vs Compressing

Know the difference

Pieter van Noordennen

Growth

Serverless Applications and Docker

How to Scale the Latest Trend in Infrastructure

Pieter van Noordennen

Growth

Slim.AI Docker Extension for Docker Desktop

How to access our Docker Extension and try it for yourself.

Josh Viney

Product

Slimming a Rails Application with DockerSlim

Dissect a simple Rails application container using DockerSlim to analyze, optimize, and deploy your product more quickly.

Theofanis Despoudis

Contributor

Where Do You Store Your Container Images?

Container Registry Options are Growing in Number and Complexity

Pieter van Noordennen

Growth

Using AppArmor and SecComp Profiles for Security Audits

Conduct better container security audits using tools like SecComp, NGINX, and Docker.

What’s in your container?

Why Docker Layers matter for container optimization

Pieter van Noordennen

Growth

Why Developers Shouldn't Have to Be Infrastructure Experts, Too

Simplifying processes required to containerize and deploy cloud-native apps.

Chris Tozzi

A New Workflow for Cloud Development

Leverage the benefits of containerization without the headaches & hassle

John Amaral

CEO

Why Don’t We Practice Container Best Practices?

Container best practices are easy to understand, hard to do

John Amaral

CEO

Better Security Audits with AppArmor and SecComp via DockerSlim

Combine the power of tools like SecComp, NGINX, and Docker.