Raspberry Docker Install

WHAT IS DOCKER

Docker is a software platform that allows you to create, test and deploy applications with maximum speed. Docker groups the software in containers that offer everything necessary for their correct execution, including libraries, system tools, etc. With Docker, you can deploy and optimize resources for an application in any environment, while always keeping an eye on the code being executed.

PREREQUISITES

  • Raspberry Pi with a running Raspbian OS

  • SSH connection enabled


For This check Raspberry Pi Setup.


1 - UPDATE AND UPGRADE

First of all make sure that the system runs the latest version of the software.

Run the command:

sudo apt-get update && sudo apt-get upgrade

2 - INSTALL DOCKER

Now is time to install Docker! Fortunately, Docker provides a handy install script for that, just run:

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


3 - ADD A NON-ROOT USER TO THE DOCKER GROUP

By default, only users who have administrative privileges (root users) can run containers. If you are not logged in as the root, one option is to use the sudo prefix.

However, you could also add your non-root user to the Docker group which will allow it to execute docker commands.

The syntax for adding users to the Docker group is:

sudo usermod -aG docker [username]

To add the permissions to the current user run:

sudo usermod -aG docker ${USER}

Check it running:

groups ${USER}

Reboot the Raspberry Pi to let the changes take effect.

4 - INSTALL DOCKER COMPOSE

Docker-Compose usually gets installed using pip3. For that, we need to have python3 and pip3 installed. If you don't have it installed, you can run the following commands:

sudo apt-get install libffi-dev libssl-dev

sudo apt install python3-dev

sudo apt-get install -y python3 python3-pip

Once python3 and pip3 are installed, we can install Docker-Compose using the following command:

sudo pip3 install docker-compose

5 - ENABLE THE DOCKER SYSTEM SERVICE TO START YOUR CONTAINERS ON BOOT

This is a very nice and important addition. With the following command you can configure your Raspberry Pi to automatically run the Docker system service, whenever it boots up.

sudo systemctl enable docker

FINISH

FINAL TIP
Find Raspberry Pi Docker Images

Raspberry Pi is based on ARM architecture. Hence, not all Docker images will work on your Raspberry Pi.

Remember that when searching for images to pull from Docker Hub. Apply the Architectures filter to search for supported apps.