How to install Docker and Docker Compose on Raspberry Pi 4
This blog post describes how to install Docker
and docker-compose
on Raspberry Pi 4. In short, to install docker and docker-compose we need to make sure that our system is up to date, install required dependencies, and install docker with docker-compose. Also, we can add our user to the docker
group to run docker without sudo.
Make sure system is up to date
sudo apt update && sudo apt upgrade -y
Install required dependencies
sudo apt install python3 python3-pip libffi-dev libssl-dev -y
Install Docker
curl -sSL https://get.docker.com | sh
Add current user to the docker group
sudo usermod -aG docker `whoami`
In order changes to be applied, we need either to re-login or to reboot the system.
Install docker-compose
Now we’re ready to install docker-compose by running
sudo pip3 -v install docker-compose
Verify everything installed and works correctly
docker run hello-world
The output will look like:
For docker-compose verifications we can create the following docker-compose.yml
file with the following content:
version: '3'
services:
hello:
image: hello-world
restart: always
container_name: hello-world
and run the command:
docker-compose up
The output will look like: