Do it your self Hobby

Install Docker and Compose on Raspberry Pi 4

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:

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

This script will do all the installation and setup.

After the installation, add pi user to docker group.

sudo usermod -aG docker pi


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:

sudo apt-get install libffi-dev libssl-dev python3-dev python3 python3-pip -y

Set the default version of Python and Pip (Optional)

sudo nano ~/.bashrc

On the top, paste this code:

alias python=python3
alias pip=pip3

Save and exit.

Paste this code:

source ~/.bashrc

We can now install the docker compose using pip

sudo pip3 install docker-compose

Let check the version of docker compose

docker-compose --version
#-->docker-compose version 1.29.1, build unknown

Finally, reboot your Raspberry Pi

sudo reboot

Follow the next tutorial:

Install MQTT and Openhab 3 in Docker Raspberry Pi 4

MQTT Openhab3 Docker Raspberry Pi 4