How to install and configure a Pi hole container on RHEL 8 - nomorespice/rhel8-howto GitHub Wiki

Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole and optionally a DHCP server, intended for use on a private network. This procedure will guide you through the installation and configuration on a Red Hat Enterprise Linux 8 server.

This document assumes that:

  • you installed the RHEL 8 x64 Operating System according to How to install RHEL 8 via kickstart
  • you are performing these tasks as root
  • you are performing these tasks in order, as some tasks require others to be completed first

Install required software

/usr/bin/dnf install -y @container-tools

Setup pi-hole container in podman

This document was tested with docker.io/pihole/pihole:latest

/usr/bin/podman volume create pihole_pihole
/usr/bin/podman volume create pihole_dnsmasq
/usr/bin/podman pull pihole/pihole

Create and start pi-hole service

Be sure to replace HOSTNAME, TIMEZONE, SERVERIP, WEBPASSWORD and DNS1 for your environment

/bin/cat <<\EOT >/usr/lib/systemd/system/pi-hole.service
[Unit]
Description=Pi-Hole Podman Container
After=nftables.service

[Service]
ExecStart=/usr/bin/podman run --name=pihole --hostname=HOSTNAME -e TZ=TIMEZONE -e SERVERIP=SERVERIP -e WEBPASSWORD=WEBPASSWORD -e DNS1=DNS1#PORT -e DNSSEC=false -v pihole_pihole:/etc/pihole:Z -v pihole_dnsmasq:/etc/dnsmasq.d:Z -p 80:80/tcp -p 53:53/tcp -p 53:53/udp pihole/pihole
ExecStop=/usr/bin/podman stop -t 2 pihole
ExecStopPost=/usr/bin/podman rm pihole
Type=idle

[Install]
WantedBy=multi-user.target
EOT

/usr/bin/systemctl enable --now pi-hole.service
⚠️ **GitHub.com Fallback** ⚠️