One piece of software that I always use on my local server is Pi-hole, it’s just too good to not have it running. I had to reinstall Pi-hole so I was thinking of trying Podman instead of Docker because it’s daemonless, rootless and it’s nice to have alternatives.
First steps
In this guide I will create the container as root because Pi-hole needs to use privileged ports(< 1024) which by default are protected from non-root users, you can lower the unprivileged port range if you want.
I’m running Ubuntu Server 22.04 LTS on a Raspberry Pi 3b.
First things first, install Podman and pull Pi-hole image.
sudo apt install podmansudo podman pull docker.io/pihole/piholeAvoid DNS conflict
Next we will need to edit systemd-resolved config because it uses port 53 for it’s DNS stub resolver which will conflict with Pi-hole.
sudo systemctl stop systemd-resolvedsudo nano /etc/systemd/resolved.conf #Sorry vim usersAdd/uncomment the following line and change it’s value to “no”.
DNSStubListener=noStart back the service and check that it is running correctly.
sudo systemctl start systemd-resolvedsudo systemctl status systemd-resolvedPodman command
This is the main command to create and start the container, remember to change the hostname, timezone and password. To update the container simply delete it and create a new one from the latest image, all configurations will be saved within Podman volumes “pihole” and “dnsmasq”.
sudo podman run -d \ --name=pihole \ --hostname=YOUR_HOSTNAME \ -e TZ=YOUR_TIMEZONE \ -e WEBPASSWORD=YOUR_PASSWORD \ -e SERVERIP=127.0.0.1 \ -v pihole:/etc/pihole \ -v dnsmasq:/etc/dnsmasq.d \ -p 53:53/tcp \ -p 53:53/udp \ -p 80:80 \ --restart=always \ pihole/piholeSystemd service
Since Podman is deamonless we have to find a way to start the container after a reboot. Fortunately, we can do this with systemd and Podman will provide us the correct configuration file.
sudo podman generate systemd --new --name pihole > pihole.servicesudo mv pihole.service /etc/systemd/systemTo finish reload systemd and start pihole.service.
sudo systemctl enable pihole.servicesudo systemctl start pihole.servicesudo systemctl status pihole.serviceNow try to connect to the web interface at device_ip/admin. If everything works correctly you should see Pi-hole dashboard.
Update container
In order to update the container firstly download the new image.
sudo podman pull docker.io/pihole/piholeThen stop the service and delete the old image.
sudo systemctl stop pihole.servicesudo podman imagessudo podman rmi OLD_IMAGE_IDIf you accidentally deleted the image before downloading the new one you won’t have a DNS resolver. You can solve this problem by, temporarily, enabling the DNSStubListener that we previously disabled.
Start the service to enable Pi-hole again.
sudo systemctl start pihole.serviceAll settings should be unchanged since we used Podman volumes.
