HOW TO: Install Docker on a Raspberry Pi

  • Post last modified:April 2, 2024
  • Reading time:5 mins read
  • Post comments:0 Comments

How to install Docker on Raspberry Pi (Debian)

What is Docker?

Docker is a platform designed to make it easier to create, deploy, and run applications by using containers:

  • Containerization: Docker utilizes containerization technology to package applications and their dependencies into standardized units called containers. Containers encapsulate everything an application needs to run, including code, runtime, system tools, system libraries, and settings.
  • Isolation: Containers provide a level of isolation, ensuring that applications run consistently across different computing environments, whether it’s a developer’s laptop, a testing environment, or a production server. Each container operates as an independent and lightweight runtime environment, sharing the host operating system’s kernel but running as isolated processes.
  • Portability: Docker containers are portable, meaning they can run on any machine that supports Docker, regardless of the underlying infrastructure or operating system. This portability makes it easy to move applications between environments, from development to testing to production, without worrying about compatibility issues.
  • Resource Efficiency: Docker containers consume fewer resources compared to traditional virtual machines (VMs) because they share the host operating system’s kernel. This efficiency allows for higher density deployments, enabling more applications to run on the same hardware without sacrificing performance.
  • Easy Deployment: Docker simplifies the deployment process by providing tools for building, distributing, and managing containerized applications. Developers can use Dockerfiles to define the application’s environment and dependencies, ensuring consistency between development and production environments. Docker Compose enables the orchestration of multi-container applications, defining complex environments with multiple interconnected services.
  • Scalability: Docker makes it easy to scale applications horizontally by adding or removing containers based on demand. Container orchestration platforms like Docker Swarm and Kubernetes further automate the deployment, scaling, and management of containerized applications, providing features such as load balancing, service discovery, and self-healing.

 

TL;DR: Docker simplifies installing programs and program packages by putting them into convenient ‘containers’ that work on any computer. It makes installing and using software easier, so you can get things done without worrying about compatibility.


  • Raspberry Pi 4/5 (at least 4gb of RAM): If you want to run multiple services (servers/applications) then you’ll need more than 1gb of ram.
  • Boot drive: Using an SD card is not an option for this, as it will wear out with frequent use. It’s best to use an SSD (get a M.2 Hat, or Bottom, and a case that can fit everything)
  • Storage: If you want to store large amounts of files, you’ll need a secondary drive other than the boot drive. (I use 2 x 12TB Nas drives in a raid enclosure, 24TB is overkill, but at least I won’t run out of storage)
  • A Debian OS, Raspberry Pi OS Lite, or DietPi, Installed. We do not need or use a Desktop for this.

 

How to Install:

Assuming you already have a copy of Debian installed and ready to go on your Raspberry Pi (Raspberry Pi OS Lite, or DietPi), if not check out my guide on Installing Raspberry Pi OS.

 

Install using the apt repository:

Before you install Docker for the first time on a new host machine, you need to set up the Docker apt repository. Afterward, you can install and update Docker from the repository.

1. Set up Docker’s apt repository. Add Docker’s official GPG key:

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

 

2. Add the repository to Apt sources:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

 

3. Now that the repository is setup, you can install the Docker package:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

 

That’s it, Docker is installed! You can test it by running:

sudo docker run hello-world

 

Next you will 100% want to install Portainer, you can check the guide, Here.


If docker-compose is not working, try:

sudo rm /usr/local/bin/docker-compose
export PATH="/usr/libexec/docker/cli-plugins/:$PATH"
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.