
Docker is a revolutionary tool that enables the containerization of applications, allowing for efficient and scalable development environments. It’s also perfectly suited for the Raspberry Pi, providing the power of containerization in a compact and affordable package. This guide will take you through the steps required to install Docker and Docker-Compose on a Raspberry Pi.
Prerequisites
To get started, ensure you have the following:
-
A Raspberry Pi device (models 3 and above are highly recommended for optimal performance).
-
The Raspberry Pi OS, preferably the 64-bit version, installed and updated to the latest version.
-
Access to the terminal on your Raspberry Pi, either directly via a connected keyboard and monitor or through an SSH connection from another device.
Step 1: Update Your System
Keeping your system updated is critical for ensuring compatibility and security. Begin by running the following commands to update your Raspberry Pi:
sudo apt-get update
sudo apt-get upgrade -yThese commands will refresh the package list and install the latest updates available for your system.
Step 2: Install Docker
Docker installation on Raspberry Pi is straightforward, thanks to the official installation script. Run the following command to install Docker:
curl -fsSL https://get.docker.com | shThis script automatically detects your Raspberry Pi’s architecture and downloads the appropriate version of Docker. It also configures the necessary settings for seamless operation.
Verify Docker Installation
After the installation completes, verify Docker’s presence and version using:
docker --versionYou should see an output similar to Docker version 24.x.x. This confirms that Docker has been successfully installed and is ready to use.
Step 3: Add User to Docker Group
By default, Docker commands require root privileges. To avoid prefixing every command with sudo, add your user to the Docker group:
sudo usermod -aG docker $USERAfter running the above command, log out and log back in to apply the changes. Alternatively, you can refresh your session without rebooting by using:
sudo su - $USERThis ensures that you can execute Docker commands without administrative privileges.
Step 4: Install Docker-Compose
Docker-Compose is an essential tool for managing multi-container applications. You can install it using one of two methods: the Python package manager (pip) or the system package manager (apt).
Method 1: Using apt (Easier Method)
For a simpler approach, you can install Docker-Compose directly from the system’s package repository:
sudo apt install docker-composeMethod 2: Using pip (Python Package Manager)
-
Install the required dependencies:
sudo apt-get install libffi-dev libssl-dev sudo apt install python3-dev sudo apt-get install -y python3 python3-pip -
Use
pipto install Docker-Compose:sudo pip3 install docker-compose
Verify Docker-Compose Installation
After installation, confirm the version of Docker-Compose with:
docker-compose versionYou should see output such as Docker Compose version v2.x.x, indicating a successful installation.
Step 5: Test Your Installation
To ensure that Docker is functioning correctly, try running a test container:
docker run hello-worldIf everything is set up correctly, you’ll see a welcome message confirming that Docker is working as expected.
You should see a message confirming Docker is installed and functioning. For Docker-Compose, create a simple docker-compose.yml file and test it:
version: '3'
services:
web:
image: nginx
ports:
- "8080:80"Run the following command in the same directory as the docker-compose.yml file:
docker-compose upVisit http://<your-pi-ip>:8080 in your browser to see the Nginx welcome page.
Troubleshooting
-
Permission Issues: If you encounter a “permission denied” error while running Docker commands, ensure that your user is added to the Docker group and restart your session.
-
Compatibility Problems: If Docker fails to install or run, verify that you’re using the 64-bit version of Raspberry Pi OS if your hardware supports it.
-
Outdated Versions: If Docker or Docker-Compose versions seem outdated, re-run the respective installation commands to fetch the latest versions.
Conclusion
Congratulations! You’ve successfully installed Docker and Docker-Compose on your Raspberry Pi. With this setup, you now have the ability to run containerized applications, develop your own projects, or deploy powerful tools like Coolify, Portainer, or other self-hosted platforms. The possibilities are endless with Docker on your Raspberry Pi, opening doors to innovation and streamlined development workflows.
Happy containerizing!

Experienced DevOps Engineer proficient in Python, Docker, Kubernetes, CI/CD, and cloud technologies. Specialized in automating processes and building scalable infrastructure for seamless development and deployment.


