this post was submitted on 18 Jun 2025
63 points (98.5% liked)

Selfhosted

44306 readers
1063 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

Hi friends.

I've been trying to find docker-compose.yaml for pihole+unbound so I can use pihole as both a recursive dns server and as local dns alongside Nginx Proxy Manager. But since v6 of pihole all the old files I could find don't work properly or at all.

Does anyone here use pihole+unbound in docker?

top 31 comments
sorted by: hot top controversial new old
[–] chris@lemmy.grey.fail 24 points 2 weeks ago (3 children)
services:

  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: sheldon
    environment:
      HOST_CONTAINERNAME: pihole
      TZ: ${TZ}
      WEBPASSWORD: ${WEBPASSWORD}
      DNSMASQ_LISTENING: "all"
      PIHOLE_DNS_1: "unbound#53"
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
      - "8080:80/tcp"
    # network_mode: host
    dns:
      - 127.0.0.1
    networks:
      dns:
        ipv4_address: 172.22.0.2
    volumes:
      - /mnt/appdata/pihole/etc-pihole:/etc/pihole
      - /mnt/appdata/pihole/etc-dnsmasq.d:/etc/dnsmasq.d
    restart: unless-stopped
    depends_on:
      unbound:
        condition: service_healthy

  unbound:
    container_name: unbound
    image: klutchell/unbound:latest
    networks:
      dns:
        ipv4_address: 172.22.0.3
    volumes:
      - /mnt/appdata/unbound:/opt/unbound/etc/unbound/custom
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "dig", "google.com", "@127.0.0.1"]
      interval: 10s
      timeout: 5s
      retries: 5

  wg-easy:
    container_name: wg-easy
    image: ghcr.io/wg-easy/wg-easy:15
    ports:
      - "51820:51820/udp"
      - "51821:51821/tcp"
    # environment:
    #   TZ: ${TZ}
    #   LANG: en
    #   WG_HOST: ${WG_HOST}
    #   PASSWORD_HASH: ${PASSWORD_HASH}
    #   WG_DEFAULT_DNS: 172.22.0.2
    #   WG_MTU: 1420
    networks:
      dns:
        ipv4_address: 172.22.0.4
    volumes:
      - /mnt/appdata/wg-easy:/etc/wireguard
      - /lib/modules:/lib/modules:ro
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=0
      - net.ipv6.conf.all.forwarding=1
      - net.ipv6.conf.default.forwarding=1
    restart: unless-stopped

networks:
  dns:
    external: true

Feel free to just delete the wg-easy service.

[–] Outwit1294@lemmy.today 4 points 2 weeks ago (2 children)

You seem knowledgeable. I have a question about this. I have ran this type of setup before. Every time, I ended up ditching unbound because it throws DNSSEC error. I have tried troubleshooting but it doesn’t work.

[–] Zanathos@lemmy.world 2 points 2 weeks ago (1 children)

I just went through my setup to verify dnssec settings in unbound to troubleshoot strange latency when removing random names while browsing. Did you verify the unbound certificate file was created and had the proper permissions? There are also a couple other configuration items in unbound related to dnssec that can be tweaked to improve the implementation.

[–] Outwit1294@lemmy.today 1 points 1 week ago (1 children)

I tried again today with baremetal and docker install but I always end up with SERVFAIL after some time.

[–] Zanathos@lemmy.world 3 points 1 week ago (1 children)

Instead of port 53, I need to run unbound on 5335 (or another obscure port).I believe I also had to make some host level changed for DNS to operate correctly for incoming requests.

Here's my podman run commands. These might have changed a bit with Pihole v6, but should still be ok AFAIK.

#PiHole1 Deployment/Upgrade Script podman run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 8080:80/tcp --hostname pihole --cap-add=CAP_AUDIT_WRITE -e FTLCONF_REPLY_ADDR4=192.168.0.201 -e PIHOLE_DNS_="192.168.0.201#5335;192.168.0.202#5335" -e TZ="America/New York" -e WEBPASSWORD=" MyPassword" -v /var/pihole/pihole1:/etc/pihole -v /var/pihole/pihole1/piholedns/:/etc/dnsmasq.d --restart=unless-stopped --label="io.containers.autoupdate=registry" docker.io/pihole/pihole:latest

#UnBound1 Deployment/Upgrade Script podman run -d --name unbound -v /var/pihole/pihole1/unbound:/opt/unbound/etc/unbound/ -v /var/pihole/pihole1/unbound/unbound.log:/var/log/unbound/unbound.log -v /var/pihole/pihole1/unbound/root.hints:/opt/unbound/etc/unbound/root.hints -v /var/pihole/pihole1/unbound/a-records.conf:/opt/unbound/etc/unbound/a-records.conf -p 5335:5335/tcp -p 5335:5335/udp --restart=unless-stopped --label="io.containers.autoupdate=registry" docker.io/mvance/unbound:latest

[–] Outwit1294@lemmy.today 1 points 1 week ago (1 children)

I used a similar docker compose config. Yesterday I learned that unbound doesn’t have root.hints by default. I downloaded it following Anudeep’s guide on Github and it was working. But within 2 hours, it started taking too long to respond and eventually stopped replying to pihole. I had to switch to cloudflare.

[–] Zanathos@lemmy.world 1 points 1 week ago (1 children)

Have you modified the default unbound config at all? This sounds like increasing the cache size limits and timeframes in the unbound config could help.

I'm actually chasing an issue I've always had where everything works great in my environment, but on mobile certain domains take ages to finally load up for me. I think it's a combination of my Pihole blocking and the amount of domains tied to a page (advertisements and tracking), but would love to figure it out. I work around it right now by flipping wifi off and on again in those instances.

[–] Outwit1294@lemmy.today 1 points 1 week ago

I have used pi-hole recommended config. I have used unbound recommended config (which feels incomplete and confusing). I have tried tweaks here and there. End result is this.

So far, the longest I have had success is with unbound docker container. The issue with that is that it seems to not be caching entries.

[–] chris@lemmy.grey.fail 1 points 2 weeks ago (1 children)
[–] Outwit1294@lemmy.today 1 points 2 weeks ago (1 children)

Not as far as I know. I have never been throttled or anything ever. I have never seen any charges.

[–] chris@lemmy.grey.fail 2 points 2 weeks ago (1 children)

I mean in terms of hijacking DNS. Might be worth a look.

[–] Outwit1294@lemmy.today 1 points 2 weeks ago

I don’t think it happens because I have used NextDNS and the logs show my activity.

[–] Octavusss@lemm.ee 3 points 2 weeks ago (1 children)
[–] chris@lemmy.grey.fail 2 points 2 weeks ago (1 children)
[–] Octavusss@lemm.ee 2 points 2 weeks ago

Deleted the WireGuard and modified few other things in docker compose file and so far it's running fine without any errors. So far do good.

[–] irmadlad@lemmy.world 3 points 2 weeks ago (3 children)

How well does that run in docker? I've always liked docker, but it seems to me that certain apps should touch metal than be containerized. Maybe I'm too old school.

[–] B0rax@feddit.org 4 points 2 weeks ago (1 children)

I have all these services in docker as well (although not with the docker compose file here) and they run perfectly fine with a very low resource footprint.

[–] irmadlad@lemmy.world 1 points 2 weeks ago (1 children)

0K that's cool. I love docker. I would like to upgrade to k8s but I haven't yet plumbed the depths of docker. I was just with the overhead of docker, since Pi-Hole/Unbound is a dedicated system, I thought maybe it'd get better thru put baked in. I wouldn't listen to me tho, I'm medicated.

[–] B0rax@feddit.org 1 points 2 weeks ago

As an anecdote: I have one system (x86) with pi-hole and unbound in a docker, and a secondary raspberry pi with pi-hole running on bare metal. The docker system (although much more performant in general) has a lower latency as the raspberry bare metal install.

[–] chris@lemmy.grey.fail 4 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

It runs quite well; Docker's not a full fledged virtual machine so much as a virtualization layer. I also love the portability of running this in Docker. I rsync a backup of this and the Appdata folder every night. When or if this server fails, I can be up and running again in minutes on another machine.

[–] Zanathos@lemmy.world 2 points 2 weeks ago

I do exactly the same thing for all three of these services! My implementation is on podman rather than docker, but basically the same deal.

[–] Appoxo@lemmy.dbzer0.com 2 points 1 week ago* (last edited 1 week ago) (1 children)

~~Focker~~ Docker container in host mode is sufficient for most cases requiring bare deployment.

[–] irmadlad@lemmy.world 1 points 1 week ago (1 children)

I've heard of Docker, Incus, k8s, VM, but not Focker. Is this some new containerization software?

[–] Appoxo@lemmy.dbzer0.com 2 points 1 week ago (1 children)
[–] irmadlad@lemmy.world 2 points 1 week ago

Hey you never know. Could be the next big thing: Focker by Mo'Fugger Industries.

[–] thagoat@lemmy.sdf.org 4 points 2 weeks ago (1 children)
[–] Vanilla_PuddinFudge@infosec.pub 2 points 2 weeks ago (1 children)

3 years ago

2 years ago

uh, nah

[–] thagoat@lemmy.sdf.org 3 points 2 weeks ago (1 children)

That's when the compose file was written. The docker images named in the file are updated constantly. Fear not ad-block seeker!

[–] Vanilla_PuddinFudge@infosec.pub 2 points 2 weeks ago

Dope. Gonna give it a spin on a vps tonight.

[–] slackarr@piefed.ca 3 points 2 weeks ago

I used to use a pihole+unbound single container docker image but technitium is just easier for me. Might be worth exploring other options like adguard home also.

[–] numblyscabbyeach@lemmy.zip 1 points 1 week ago