How to install Docker on Raspberry pi with Raspbian?

Docker is a container system that doesn't require many resources to run containers, making it very lightweight . Therefore, Docker can be a perfect candidate for developing and testing web applications on Raspberry Pi.

Of course, you can do other things like run a web server, a proxy server, or a database server and more in Docker on a Raspberry Pi.

If you are still unfamiliar with Docker, you should know that it is an open-source project that automates the deployment of applications within software containers , providing an additional layer of abstraction and automation for application virtualization across multiple operating systems.

Docker uses Linux kernel resource isolation features, such as cgroups and namespaces , to allow independent "containers" to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines.

Preparing the Raspberry Pi

Installing Docker on your Raspberry Pi is straightforward and quite simple . In this tutorial, we'll use the official Raspberry Pi operating system, Raspbian, as our base.

If you don't already have this system installed on your Raspberry Pi, you can consult the following article where we explain how to do it quite simply. The link is here.

With Raspbian now installed on our Raspberry Pi, we will update the packages and the Raspbian APT package repository cache using the following command:

sudo apt update

Now, you have to update all new software packages that have been detected from Raspbian. For this we just have to execute the following command:

sudo apt upgrade

At this point, the software packages need to be updated.

Now, you need to install the kernel headers for your operating system. This is important, because if you don't install the kernel headers, Docker won't work.

To install the kernel-headers, all you have to do is run the following command in the terminal:

sudo apt install raspberrypi-kernel raspberrypi-kernel-headers

With all of the above ready, we can now proceed to the Docker installation on our beloved Raspberry Pi, since we are totally sure that we have all the updated packages in the system.

Install Docker on Raspberry Pi

We install Docker by running the following command in the terminal:

curl -sSL https://get.docker.com | sh

This download and installation process can take a while, so I suggest you take your time.

Docker

Now that Docker is installed on our Raspberry Pi system, we can begin the process of implementing Docker so that we can use it.

The first step is to add your system user "pi" (the default user in Raspbian) to the docker group. This will allow you to create and manage Docker containers, images, volumes, etc., without sudo or superuser privileges.

If you created a different user, you must replace “pi” with your username in the command. To add the pi user to the Docker group, simply run the following command:

sudo usermod -aG docker pi

Having made this change, we will now need to restart our system so that the changes are loaded at system startup and our user's addition to the Docker group is applied.

They can reboot their system by running the following command in the terminal:

sudo reboot

Once the system has restarted, log back in and open a terminal. Run the following command to verify that Docker is installed and running on the system:

docker version

As you can see, Docker is working perfectly on your Raspberry Pi already.

Now you just need to deploy your first container. You can find one on the Docker website, which features many applications. Here's the link.


Add as preferred source in Google