4. PiHole setup & maintenance - nerdily/Raspberry-Pi-Docker-Swarm GitHub Wiki

Persistent storage locations:

Ensure these directories exist before starting the Pihole stack (otherwise the stack won't start):
/mnt/glusterfs/pihole/etc-pihole/
/mnt/glusterfs/pihole/etc-dnsmasq.d/

Test that GlusterFS is replicating across the cluster storage

pihole.yml

version: '3.4'
services:
  pihole:
    image: pihole/pihole:latest
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
        max_attempts: 3
    volumes:
      - pihole_etc:/etc/pihole
      - pihole_dnsmasq.d:/etc/dnsmasq.d
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      - TZ='America/New_York'
      - WEBPASSWORD=set_a_password
      - PIHOLE_DNS_:127.0.0.1;1.1.1.1
      - ServerIP=127.0.0.1
      - VIRTUAL_HOST=pi.hole
    dns:
      - 127.0.0.1
      - 1.1.1.1
    deploy:
      placement:
        constraints:
          - "node.role == worker"
volumes:
  pihole_etc:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /mnt/glusterfs/pihole/etc-pihole
  pihole_dnsmasq.d:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /mnt/glusterfs/pihole/etc-dnsmasq.d

By constraining the node.role to worker, it ensures we don't spin up the PiHole on a Swarm Manager.

Launch the stack

docker stack deploy --compose-file=/mnt/glusterfs/configs/pihole/pihole.yml pihole

Updating Pihole container to latest

See here for more but basically:

  1. Update latest pihole image: docker pull pihole/pihole
  2. Stop and destroy current pihole container: docker stack rm pihole
  3. Restart the stack: docker stack deploy --compose-file=/mnt/glusterfs/configs/pihole/pihole.yml pihole

Resetting the PiHole admin password

Persistent storage should mean the password keeps, but if it does get reset, can find it with:
docker logs pihole | grep random

Spin up a shell in the pihole container: sudo docker exec -it pihole bash

Set a new password: sudo pihole -a -p