Raspberry Pi Install Docker

You can also follow this Pi-focused guide by Docker captain Alex Ellis. One way you can use Raspberry Pi and Docker together is for Swarm. Used together, they can create a computer cluster. With Swarm containers on a bunch of networked Raspberry Pis, you can build a powerful machine and explore how a Docker Swarm works. Sudo pip3 install docker-compose. 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.

Docker become very popular these days. Its a method of packaging your code, libraries etc. And by using docker compose, you can run the software on multiple devices without much setup.

The easiest way to install docker is to download and run the docker script. To accomplish this, run this command:

This script will do all the installation and setup.

Raspberry pi install docker 2021

After the installation, add pi user to docker group.


Install Docker Compose on Raspberry Pi

If you have received an error docker-compose command not found, it is because it is not yet installed. To install this, first we need to install Python & Pip.

Paste this:

Set the default version of Python and Pip (Optional)

On the top, paste this code:

Save and exit.

Paste this code:

We can now install the docker compose using pip

Let check the version of docker compose

Finally, reboot your Raspberry Pi

Follow the next tutorial:

Raspberry Pi Install Docker Compose

I have written about installing Docker and Docker Compose on Raspberry Pi OS in this article. But until now I could not install Mongo DB database on Raspberry Pi despite that there is docker image for ARM processors. The reason is that latest database versions does not support 32-bit ARM architecture. Raspberry Pi computer supports 64-bit instructions since version 3 release, but operation system Raspberry Pi OS (previously called Raspbian) is 32-bit system. To get real 64-bit computer you should install 64-bit Ubuntu or now there is opportunity to use Raspberry Pi 64-bit beta version.

Installing Raspbery Pi OS

For now it is beta version, so some features, programs are not available or may have bugs. We can expect that after some time it will be fully released. Usually using 64-bit version has more performance and also it can address more than 4 Gb of RAM. So I think in future ARM64 OS version will be used in most cases. Only Raspberry 2 and previous version does not support 64 bit instructions, so there is no choice what version to use. Also Raspberry Pi Zero has older processor without 64-bit instructions support.

Similar to 32-bit OS, you can download two versions of ARM64 operating system:

  • Raspberry Pi OS ARM64 full version - full version includes desktop and recommended software. Can be used for desktop computer.
  • Raspberry Pi OS ARM64 lite version - lite version does not include desktop and have minimum installed software. This version is ideal for computer that works as server.

For Mongo DB or other images for server the best choice is lite version. Download image and write it to SD card. I will not describe how to do it. There are instructions on raspberrypi.org

After writing image to SD card insert it into Raspberry Pi 3/4, connect it to monitor add keyboard and switch it on. First time load takes more time than it usually takes. After that using program raspi-config enable SSH connection, change name, set password, connect to WiFi (wired connection is recommended for server for more stability).

You may want to check if it is really 64-bit, not 32-bit version. It can be done with this command

Result will be something like this

As you can see, architecture is arm64

To check particular application, can use this command to get installation path

Result

Then can check program

Result

So now we are sure that we have installed 64-bit Raspberry Pi OS.

Raspberry Pi Install DockerRaspberry pi install mosquitto docker

Install Docker

I did not invent the way how to install 64-bit Docker. I have found this article in the internet. In my article I will write only short description and commands.

  1. Install required packages

2. Get docker signing key

3. Add docker repositories

4. And finally install Docker

5. At last run these command to start docker and run it every time the system boots

Unfortunately after installing Docker I could not run hello-world image because of some missing permissions. Adding permissions is described in my previous article about installing Docker, but I will write commands one more time.

  1. Create docker group if it is not already created.

2. Add current user to docker group. By default it will be pi user, but you can set also different user

3. Run command for the changes to take effect

Now you can test Docker and run test image

Result should be something like that

Install Docker Compose

With docker compose you can easier to run multiple containers, save configuration in one yml file. Installation process is even simpler than that is used for Docker.

Install
  1. Install required packages
Raspberry Pi Install Docker

2. Install Docker Compose, this can take some time

Raspberry Pi Zero Install Docker

Conclusion

Raspberry Pi Install Docker

Now we have installed Docker for 64-bit operating system and can use 64-bit images from Docker Hub. Images for arm64 are marked with arm64 or arm64/v8 tag. For example Mongo looks like this

Raspberry Pi Install Docker

So there is image not only for x86-64, but also for ARM64. 64-bit version of Raspberry Pi OS gives more opportunities, performance for running mini server on Raspberry Pi computer.