How to install Docker on Raspberry pi with Raspbian?

Docker is a container system that you don't need a lot of resources to run containers, so It's very light and that therefore Docker may be a perfect candidate for web application development and testing on Raspberry Pi.

Of course, it 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 still don't know about Docker, you should know that this is an open source project that automate application deployment within software containers, providing an additional layer of application virtualization abstraction and automation across multiple operating systems.

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

Preparing the Raspberry Pi

Installing Docker on our Raspberry Pi is nothing to write home about and its installation is quite simple. In this tutorial We will take as a basis the official system of our Raspberry which is Raspbian.

If you still do not have this system installed on your Raspberry, you can consult the following article where we explain how to do it in a fairly simple way. The link is this. 

Already with Raspbian installed on our Raspberry pi, we are going to update the packages and the Raspbian APT package repository cache with 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 have to install the kernel-headers for the 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

Docker installation We do it by executing 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

With the installation of Docker in the system of our Raspberry Pi, now we start with the implementation work Docker so you can use it.

For this the first step is add our system user "pi" (Raspbian default) to the docker group. Thus, you will be able to create and manage containers, images, volumes, etc. docker without sudo or superuser privileges.

If they created a different user, they must change "pi" to their username in the command. To add the pi user to the Docker group they just have to run the following command:

sudo usermod -aG docker pi

Made this change now, it will be necessary to perform a restart of our system, so that the changes made are loaded at system startup and the addition to our user's Docker group is applied.

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

sudo reboot

Once the system has been restarted, we will enter it again and we will open a terminal. In it we are going to execute the following command to verify the installation of Docker and that it is already running on the system:

docker version

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

Now you just have to implement your first container. To do this, you can search for one on the Docker page, which features many applications. The link is this.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.