You are currently viewing How to Install Docker on Raspberry Pi

How to Install Docker on Raspberry Pi

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

Installing Docker on Raspberry Pi

To install Docker on your Raspberry Pi, follow the instructions below:

  1. Update and upgrade the RPi system.
  2. Download and install Docker using the installation script.
  3. Allow a non-root user to execute Docker commands.
  4. Verify installation by checking the Docker version.
  5. Test the setup by running a “hello-world” container.
  6. 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).

sudo apt update && apt upgrade
Figure (1) Update and upgrade RPi

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
sudo sh get-docker
Figure (2) The output of using Docker’s running command.

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.

Add user to docker group on raspberry pi
Figure (3) adding a user to the docker group.

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

docker id
Figure (4) Check if the user was added to the docker group.

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.

verify docker installation on Raspberry Pi
Figure (5) output of docker version

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

Author

  • Mustafa Al-Adhami

    Dr Mustafa Al-Adhami is a distinguished architect, technologist, and educator with over a decade of professional experience in the built environment. He is currently a faculty member at Birmingham City University (BCU), where he is renowned for his expertise in computer modelling, simulation, machine learning, and reality capture technologies, including remote sensing and the Internet of Things. Dr Al-Adhami’s diverse skill set and extensive knowledge of advanced technologies make him a leading figure in his field.

    View all posts

Leave a Reply