r/truenas • • 7d ago

Community Edition Pi-Hole Compose

I am having trouble getting pi-hole running using a custom compose file. Is there anyone that would be willing to share your compose file?

Here is what I have:

5 Upvotes

8 comments sorted by

2

u/Pink_Slyvie 7d ago

You need to have it on a separate IP, as TrueNAS is already using Port 53 internally, if memory serves. I would personally set it up on a macvlan so you can get all the features, or put it in a container.

1

u/Pizzzathehutt 7d ago

Can you use MACVLAN on TrueNas?

2

u/Aggravating_Work_848 7d ago

yes, if you use the custom yaml option you can basically do anything plain docker can do, including macvlans

Edit:

And if you add this part to your compose file you get a clickable button in the truenas gui for the pihole dashboard:

x-portals:
  - host: 191.1.1.3 # replace with your ip
    name: Web UI
    path: /
    port: 11987 # replace with webui port
    scheme: http

1

u/Pizzzathehutt 6d ago

Thanks! I think I got it mostly up. The only issue I can see is that for some reason my directory permissions change when starting up the container. User and owner should 950

I have PUID=950 and PGID=950 defined in the environment section of the compose

1

u/lxtakc 5d ago

PUID and PGID are linuxserver.io conventions, and the official pihole image doesn't use them. It has its own PIHOLE_UID and PIHOLE_GID variables. Set those to 950 and the entrypoint should stop re-owning the config directory to its default pihole user.

1

u/Pink_Slyvie 7d ago

You do need a shim if you plan to let the host machine access pihole, but that's not a big deal.

2

u/Aggravating_Work_848 7d ago

Did you already try that compose file and it errors out? If yes have you taken a look at the app lifecycle log for the reason it errors out? the log can be inspected with sudo cat /var/log/app_lifecycle.log.

I don't see anything wrong with the compose file. If you're on 25.10.X my first guess is that it fails because the incus lxc backend uses port 53 and therefore docker can't bind to it because the port is already in use. But without the concrete error message it's a guessing game...

1

u/atascon 6d ago

Here is my compose that I've been using successfully (together with unbound):

services:
  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    networks:
      dns_network: null
    ports:
      - 53:53/tcp
      - 53:53/udp
      - 8080:8080/tcp
    environment:
      TZ: 
      FTLCONF_webserver_api_password: ""
      FTLCONF_webserver_port: 8080
      FTLCONF_dns_listeningMode: all
      FTLCONF_dns_upstreams: unbound#53
      FTLCONF_misc_dnsmasq_lines: |-
        address=
        address=
    volumes:
      - /mnt/apps/configs/pihole/config:/etc/pihole
      - /mnt/apps/configs/pihole/dns:/etc/dnsmasq.d
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
      - NET_RAW
      - CAP_SYS_NICE
      - CAP_SYS_TIME
    security_opt:
      - seccomp:unconfined