Setting up PiHole using Docker, trouble with IP / Network Interface

I’m looking to set up PiHole on my TrueNAS SCALE (EE) setup. I installed the version from the app library, and assigned it br0 as the network interface in the UI. This worked - when I set my computer’s DNS to the IP of the NAS (10.0.0.253), it picked up DNS from PiHole without issue. So far, so good.

Because I want a touch more control over my own Docker apps, I’m using my own YAML files to create them - this way, I can simply paste them back in if rebuilding a system, rather than having to go through the UI for each one. (Also, I am not 100% sure if the ix-apps dataset is backed up when I back up my main dataset - it doesn’t seem to appear on my backup disks, but that’s another topic.)

When I use my own YAML file, the internal IP that PiHole shows is 172.16.10.2 - but when I had it as the Library App, it showed 10.0.0.253. How can I update my YAML file to use the IP address of the TrueNAS itself?

YAML Below:

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      # DNS Ports
      - "53:53/tcp"
      - "53:53/udp"
      # Default HTTP Port
      - "8081:80/tcp"
      # Default HTTPs Port. FTL will generate a self-signed certificate
      - "4433:443/tcp"
      # Uncomment the below if using Pi-hole as your DHCP Server
      #- "67:67/udp"
    environment:
      - PUID=568
      - PGID=568
      - TZ=America/New_York
      - FTLCONF_webserver_api_password=(Redacted)
    volumes:
      - /mnt/data/apps/pihole:/etc/pihole
    #cap_add:
      # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
      # Required if you are using Pi-hole as your DHCP server, else not needed
      #- NET_ADMIN
    restart: unless-stopped
1 Like

If it helps any, I have br0 defined for my VM already.

This can be disregarded - I tried AdGuard Home, and it’s working without issue. Sane functionality, easier setup.

2 Likes

OK, so coming back to this - AdGuard crashed today, hosing everyone in my house that works from home. I’m looking back at PiHole now, with the experience I gained from setting up AdGuard.

The trick to making this work is two fold: using “network_mode: host” and then changing the port that the Web UI runs on. The issue I was running into is that PiHole defaults to 80 / 443, which TrueNAS already uses, so just using the host network did not work. AdGuard defaulted to 3000 for setup, so I was able to get around this, set the port manually, and learn.

My updated compose.yaml for this app is, as follows. Note you will want to edit the Ports to match your needs:

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    network_mode: host
    environment:
      - PUID=568
      - PGID=568
      - TZ=America/New_York
      - FTLCONF_webserver_api_password=(Still Redacted)
      - FTLCONF_webserver_port=3000,3001s
    labels:
      - "com.centurylinklabs.watchtower.monitor-only=false"
    volumes:
      - /mnt/data/apps/pihole:/etc/pihole
    cap_add:
      # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
      # Required if you are using Pi-hole as your DHCP server, else not needed
      - NET_ADMIN
    restart: unless-stopped

For my own curiosity, if you had the truenas PiHole app running properly, why did you not use the settings in the app, like the port number, in the yaml?

I had the app running before with the Network using the Docker network, but this caused issues with PiHole thinking it was not on the same network as the rest of my house. PiHole saw itself with a 172.x.x.x address, where everything else was on 10.0.0.x - this made it harder for it to serve up DHCP, etc.

By moving PiHole to the Host network, it’s now on 10.0.0.x, but now there’s the port conflict for 80 & 443. I was able to get around this with the Docker environment variables.

Did that make sense?

Yes, setting PiHole as the DHCP server would be tricky on Truenas.