With the new Raspberry PI OS, it’s interesting to check if some basilar installations are going to be as simple as with previous version.
Today’s goal is to setup a docker environment and Portainer with Raspberry PI OS Lite. It will be tested on a Raspberry Pi model A+ but the procedure is the same also for other Raspberry Pi hardware (Pi 4, PI3 model B+, PI 3 Model B).
What we need
To setup our docker environment using the new Raspberry Pi model A+, we’ll not use keyboards or TV cables. Our OS installation will provide a basis having already WiFi and SSH ready to be used at first boot.
I suggest adding from now to your shopping chart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from shopping chart.
- Raspberry PI 3 Model A+ (including proper power supply or using a smartphone micro usb charger with at least 3A) or newer Raspberry PI Board
- high speed micro SD card (at least 16 GB, at least class 10)
Check hardware prices with following links:
Step-by-step guide to setup Docker
Setup process is really simple.
Before going on Docker installation, be sure to have an updated OS:
sudo apt update sudo apt upgrade
The default (and suggested) Docker installation comes with convenience script, a simplified sh script which makes all for you. Typr from terminal the following lines:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh
It will take a few minutes to complete installation. At prompt, test it by typing:
sudo docker version
You can also test docker by running the default hello-world image:
sudo docker run hello-world
If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group. To accomplish it for default pi user:
sudo usermod -aG docker pi
You will need to logout and login (or reboot) to make it working or you will have still permission issues using docker without sudo.
A graceful web GUI helping in managing containers is portainer. In our case, we need to install an arm compatible version:
docker pull portainer/portainer:linux-arm docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer:linux-arm
Now you can reach your docker server with a browser, just connecting to https://<<RaspberryIpAddress>>:9000.
You will be required to set your default password for admin user, then you will be prompted to portainer GUI:
Docker-compose enables your Docker environment to use yaml files to compose and quickly boot complete services. Its official page suggest installation with pip3, but this sometimes results not wirking. So, I suggest to use the more resilient apt installation using default repositories, with following command from terminal:
sudo apt install docker-compose
Verify your docker-compose installation by typing:
Enjoy your Docker environment inside the Raspberry PI!