Pihole runs great on a Raspberry Pi, but what about other devices? If you have a server lying around that can run Docker, Pihole will work.
Pihole was created to run on Rasbperry Pi devices, but this shouldn’t be limited to device. There is an official Docker image that can be used on any device that can run Docker. The only caveat is that you’ll need to manually update the container when a new version comes out. Luckily, the following guide will show you how to do it with a script.
Make sure you have a device capabile of running Docker first.
docker pull pihole/pihole
piholerunning, stop it, and remove the container
docker stop pihole docker rm -f pihole
sudo mkdir /opt/pihole sudo touch /opt/pihole/docker-compose.yml sudo touch /opt/pihole/resolv.conf cd /opt/pihole
docker-compose.ymlfile should look something like the following. This is what you’ll be running each time you get a new container
version: "3" # https://github.com/pi-hole/docker-pi-hole/blob/master/README.md services: pihole: container_name: pihole image: pihole/pihole:latest # For DHCP it is recommended to remove these ports and instead add: network_mode: "host" ports: - "53:53/tcp" - "53:53/udp" - "67:67/udp" - "80:80/tcp" environment: TZ: 'America/Toronto' # WEBPASSWORD: 'set a secure password here or it will be random' # Volumes store your data between container upgrades volumes: - './etc-pihole:/etc/pihole' - './etc-dnsmasq.d:/etc/dnsmasq.d' - './resolv.conf:/etc/resolv.conf' # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: - NET_ADMIN restart: unless-stopped # Recommended but not required (DHCP needs NET_ADMIN)
resolv.confshould look like the following. This is required so you can update your lists in
search home nameserver 127.0.0.1 options ndots:0
docker-compose up -d
piholeis up and running, check your device’s IP address and go to
http://<device-ip>/adminto login with what ever password you’ve set. If it’s working, remove any old
docker image prune -f
Because we’re mounting files to the Docker container, we can pull the latest
pihole image and spin up new containers with the
docker-compose.yml file that mounts the persistant files back in place. Because the
pihole images get updated every month, you can automate this task with a shell script. Create
update_pihole.sh and add the following:
#! /bin/bash docker pull pihole/pihole docker stop pihole docker rm -f pihole docker-compose -f /opt/pihole/update_pihole.sh up -d docker image prune -f
To automate this further, you can create a
cronjob in Linux by doing the following:
chmod +x ~/update_pihole.sh
crontab -eto edit our cronjobs. (I used
/bin/nanobut you can use whatever you want.)
update_pihole.shscript on the first of each month at midnight.
0 0 1 * * /opt/pihole/update_pihole.sh
crontab: installing new crontab.
service cron status
cronis not running, start the service:
sudo cron start