How to Install Docker on a Raspberry Pi 5: A Step-by-Step Guide
The Raspberry Pi 5 is a powerful single-board computer perfect for building efficient and compact compute clusters. One of the most popular tools for deploying and managing containers in these clusters is Docker. Docker allows you to package applications into lightweight, portable containers, making it an excellent choice for microservices, development, and testing environments.
In this guide, we’ll walk you through the process of installing Docker on a Raspberry Pi 5 running Raspberry Pi OS.
Step 1: Update and Prepare the Raspberry Pi
Before installing Docker, ensure your Raspberry Pi is running the latest software.- Open a terminal on your Raspberry Pi or SSH into it.
- Run the following commands to update the system:
bash
sudo apt update && sudo apt upgrade -y
- Reboot the Raspberry Pi to apply any kernel updates:
bash
sudo reboot
Step 2: Install Required Dependencies
Docker requires some essential packages to be installed first.- Once the Raspberry Pi reboots, open the terminal and run:
bash
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
Step 3: Download and Add Docker’s Official GPG Key
To ensure secure installation, add Docker’s GPG key and repository.- Add Docker’s GPG key:
bash
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Add the Docker repository for ARM64:
bash
echo "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 4: Install Docker
- Update the package list to include Docker’s repository:
div class="code-window">
bash
sudo apt update
- Install Docker:
div class="code-window">
bash
sudo apt install -y docker-ce docker-ce-cli containerd.io
- Verify that Docker is installed correctly:
div class="code-window">
bash
docker --version
You should see the Docker version displayed, confirming a successful installation.
Step 5: Configure Docker
- Add your user to the Docker group to avoid using sudo with Docker commands:
bash
sudo usermod -aG docker $USER
- Log out and log back in to apply group changes, or run:
bash
newgrp docker
Step 6: Test Docker
- Run a simple Docker container to ensure everything works:
bash
docker run hello-world
Docker will download the hello-world image, run it, and display a message confirming that Docker is installed and working correctly.
Step 7: (Optional) Enable Docker to Start on Boot
- To ensure Docker starts automatically when your Raspberry Pi boots:
bash
sudo systemctl enable docker
Conclusion
Docker is now installed and configured on your Raspberry Pi 5. With Docker, you can containerize applications, set up microservices, or create a powerful PicoCluster for distributed computing tasks.
If you’re looking to build multi-node clusters, consider using PicoCluster Raspberry Pi 5 to create scalable and portable compute environments with ease. Happy clustering!