Just a few hours left to save! Use code BLACKFRIDAY_2024 for a discount off your entire order. Sale ends tonight at MST US.

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.
  1. Open a terminal on your Raspberry Pi or SSH into it.
  2. Run the following commands to update the system:
    bash
    sudo apt update && sudo apt upgrade -y
    
  3. 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.
  1. 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.
  1. 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
    
  2. 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

  1. Update the package list to include Docker’s repository: div class="code-window">
    bash
    sudo apt update
    
  2. Install Docker: div class="code-window">
    bash
    sudo apt install -y docker-ce docker-ce-cli containerd.io
    
  3. 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

  1. Add your user to the Docker group to avoid using sudo with Docker commands:
    bash
    sudo usermod -aG docker $USER
    
  2. Log out and log back in to apply group changes, or run:
    bash
    newgrp docker
    

Step 6: Test Docker

  1. 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

  1. 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!

Leave a comment

Please note, comments must be approved before they are published