Putting Docker, Pi-Hole, etc. on my Raspberry Pi 3 Model B
18 Apr 2023The last Raspberry Pi I bought was a version 3 Model B. Initially it served me well as a Kodi streaming box and as console for playing Super Mario 3 via EmulationStation. Both use cases vanished when I got an Apple TV where I run Infuse and Provenance. So the Pi was put into storage with its two unused Version 1 siblings. Fast forward to April 2023, my friend Miguel told me he put Docker on his Pi and runs some containers on top of it. I always wanted to try Pi-Hole but never took the time to give it a go.
On my Mac I used the official Raspberry Pi OS Imager to put the operating system on my micro SD card. My mind was mildly blown by how much that tool has evolved, giving options to already configuring the hostname, setting up the user, authorized_keys
, Wifi, locale and keyboard.
Docker
Getting Docker up and running was also just a matter of punching in a few commands:
Clean up once the installation succeeded:
Portainer
To make managing Docker easier Miguel recommended installing Portainer. You can simply install the Community edition and run it in a container. Here is a link to the guide I followed. The installation was straight forward:
After that I was able to complete the setup in the web frontend, which is available on port 9443
of your Pi’s IP address, e.g. https://192.168.0.200:9443.
Pi-Hole
To get Pi-Hole up and running I first changed the app templates URL in Portainer to pi-hosted’s list: https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/template/portainer-v2-arm64.json.
Now we have a massive amount of application templates available:
I went with the basic Pi-Hole templates. With pretty much one click we get a working instance with ports and volumes mapped ✨. By default the Pi-Hole webinterface will be available on port 1010
of you Pi’s IP address, e.g. http://192.168.0.200:1010/admin/. To (re-)set the admin password open a shell from Portainer and run this command: sudo pihole -a -p
On your local machine you can now verify that Pi-Hole is running correctly by asking it to resolve a domain name (replace the IP address with your Pi’s IP):
If you get a proper response you are good to go. On a Mac open your System Settings application and navigate to Network, your current network device, click “Details…” and go to “DNS”. Here you can add your Pi’s IP address (and maybe remove the others).
To prevent all sorts of weirdnesses I recommend flushing the DNS cache and rebooting the machine:
Now we can enjoy (almost) ad-free browsing! Be sure to repeat this for all of your device where you want to see ads blocked.
Outlook
The experience so far was pretty smooth and I’m looking forward to using Docker more for my side projects. I want to write a small backend with Swift Vapor and dockerize an existing Rails application. In the vast amount of application templates I identified a few that I’ll try soon: