Skip to content

Instantly share code, notes, and snippets.

@grangerx
Forked from janfrode/pihole-centos8-podman.md
Created January 25, 2023 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grangerx/95a512c688b937deda82e0569fdbe373 to your computer and use it in GitHub Desktop.
Save grangerx/95a512c688b937deda82e0569fdbe373 to your computer and use it in GitHub Desktop.
Pi-hole in podman in Centos8

These were the steps I needed to perform to run pi-hole in a podman container on Centos8/RHEL8:

First I got it running in podman with the environment I needed (information on additional settings is available from https://hub.docker.com/r/pihole/pihole):

# podman run -d -p 53:53/udp -p 80:80/tcp -e DNS1=1.1.1.1 -e DNS2=8.8.8.8 --name pi-hole -e WEBPASSWORD=admin-password-here  docker.io/pihole/pihole

Then I created a systemd service for it:

# cat <<'EOF' > /etc/systemd/system/pi-hole-container.service
[Unit]
Description=Pi-hole container

[Service]
Restart=always
ExecStart=/usr/bin/podman start -a pi-hole
ExecStop=/usr/bin/podman stop -t 2 pi-hole

[Install]
WantedBy=local.target
EOF

And finally killed my running container and verified that it got started from the systemd service:

# podman kill pi-hole
# systemctl enable pi-hole-container.service 
# systemctl start pi-hole-container.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment