Docker is a tool for creating, deploying, and running applications in containers. Docker containers are extremely light when compared to virtual machines.
Docker is a popular development tool. it streamlines the development process while consuming less resources. This feature is valuable for using Raspberry Pi (RPi) as a home server.
In this article, we are going through a step-by-step guide on installing Docker on Raspberry Pi.
Requirements
- RPi with Raspberry Pi OS up and running
- SSH connection enabled (For best practice)
Installing Docker on Raspberry Pi
To install Docker on your Raspberry Pi, follow the instructions below:
- Update and upgrade the RPi system.
- Download and install Docker using the installation script.
- Allow a non-root user to execute Docker commands.
- Verify installation by checking the Docker version.
- Test the setup by running a “hello-world” container.
- Next Step
Now let’s take a closer look at these steps.
Step 1: Update and Upgrade
To begin, update and upgrade the system. Open a terminal window and run the following commands:
sudo apt update
sudo apt upgrade -y
Or use the following command:
sudo apt update && sudo apt upgrade -y
This step is necessary to ensure the recent version of the software is installed, See figure (1).
Step 2: Download and install Docker on Raspberry Pi
Now to install docker on raspberry pi, download the docker’s official installation script using curl the below command. If you are suspicious, you can check the script URL: https://get.docker.com
curl -fsSL https://get.docker.com -o get-docker.sh
Now run the script using the command below, see Figure (2).
sudo sh get-docker.sh
Step 3: Add a User to the Docker Group on Raspberry Pi
Users with administrative permissions (root users) are the only ones who can execute containers. Sudo prefix can also be used if you are not logged in as a root user.
However, you could also add your non-root user to the Docker group, allowing it to execute docker commands. To do that, use the following command:
sudo usermod -aG docker [user_name]
Figure (3) is an example of adding a user to the docker group. There is no specific output if the process is successful.
To check reboot your RPi and use the command (id). You should see your user ID is added to the docker group see figure (4).
Step 4: Check the Docker version and information
For checking the Updated Docker Version and info details on your Raspberry Pi, refer to the below command.
docker version
Figure (5) shows the docker version with all the relevant details.
Run the command below to get system information, including a list of containers, kernel version, and Docker images.
docker info
Step 5: Verify Docker’s setup on Raspberry Pi
Running the Hello World container is the best approach to verify the Docker setup. To do so, enter the following command:
docker run hello-world
The “hello-world” image will be pulled from the Docker daemon. An output from Docker will show the following message:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Next Step
You are now ready to use Docker on Raspberry Pi and run isolated and lightweight applications using containers.
The following tutorial will include installing some of the services to run Raspberry Pi as a home server.
To know more about some of the services check this article.
Conclusion
This article focused on installing Docker on Raspberry Pi step-by-step with an example. Docker is a lightweight tool and very useful for running Rpi Applications. The main goal of this tutorial is to enable running a cheap and affordable home server in every house. There are many services that can be easily replaced by a raspberry pi home server. If you are interested read our previous articles about the home server.
The following is a list of the commands that were used in this tutorial:
sudo apt update
sudo apt upgrade -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker [user_name]
docker version
docker info
docker run hello-world
What to do?
- Subscribe to our Newsletter.
- Follow our pages on social media Facebook, Twitter, Instagram and LinkedIn.
- Leave us a comment.
- For more information Contact Us.
- Don’t forget to Check Our Other Articles.
THANK YOU & HAVE A WONDERFUL DAY!