Today we are going to look at how to install Docker and Portainer on a Raspberry Pi.
This process is very simple, but we will be using Portainer in future tutorials to setup different docker containers, so this will be the first thing we are going to look at. The Raspberry Pi 4 is pretty powerful for being as small as it is. Combine that with the fact that there are a ton of great docker containers that don’t require powerful CPU’s, running certain Docker containers on a Raspberry Pi becomes a great option for a lot of people.
The steps below will utilize a fresh install of the Raspberry Pi OS. If you aren’t sure how to do that, I have instructions here.
Instructions - Install Docker and Portainer on a Raspberry Pi
1. Ensure that your Raspberry Pi is up to date by running the commands below.
sudo apt update
sudo apt upgrade
2. The next thing we are going to run is the script to install Docker on our Raspberry Pi. Portainer is a GUI that manages Docker containers, so we need to ensure Docker is installed.
curl -sSL https://get.docker.com | sh
3. After the script completes, we need to give our Pi user account access to Docker.
sudo usermod -aG docker pi
4. After the user has been added, we are going to run a command to download the latest Portainer image for the ARM processor (which is what the Raspberry Pi uses).
sudo docker pull portainer/portainer-ce:linux-arm
5. Our final step is to create a new container that will run Portainer. If you are already using port 9000 on your Raspberry Pi for something else (this is unlikely), you will need to change the ports below.
sudo docker run --restart always -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:linux-arm
6. You should now be able to navigate to the IP address of your Raspberry Pi and port 9000 to access Portainer. When you get there, create a username and password.
7. Select Local and Connect.
8. You should now be connected to Portainer!
This is a pretty straight forward process, but we will be utilizing it in future tutorials. I decided it was best to create a specific tutorial for this rather than installing Docker/Portainer in all future tutorials. If you have any questions, please leave them in the comments. Stay tuned to see what containers we will be adding to our Raspberry Pi! Thanks for reading!