Skip to content

Pi-hole & Unbound in Container Manager on a Synology NAS

Last updated on 27 February 2025

Important or Recent Updates
Historic UpdatesDate
Updated guide for Container Manager and using Macvlan14/05/2023
Added a new section to ensure DSM continues having network access.02/06/2023
Guide updated so you can choose between Macvlan or Bridge mode12/08/2023
Added additional security option to the compose to restrict the container from gaining new privileges25/10/2023
Fixed issues I introduced with the recent changes in my mission to make things more secure. It was so secure I broke it!
Added the appropriate permissions/capabilities at start up for the container.
29/10/2023
Removed the requirement for the synobridge as this container can just use its own bridge, and added the Host network mode, so all three are a choice.28/01/2024
Removed the WEB_UID and WEB_GID from the config to avoid issues with ID’s conflicting inside the container. I will update again once I have some time to work around this.03/04/2024
Some minor amends to sync up the information across this guide and the AdGuard one01/08/2024
Removed two unneeded capabilities from the bridge version of the docker compose as they are not required.16/11/2024
Guide updated for the all new v6 of Pi-hole (Note if you upgrade from v5 you effectively have to change all the compose settings in line with the new guide so might be worth just scrapping and starting fresh unless you really need stats etc

Please note as recommended by the Pi-hole dev team I have added a Watchtower exclusion label to the compose so you can do manual updates. Automated ones could result in you losing internet access if a bad update takes place.

Edited again today as I left in a variable that is not required in Host and Macvlan mode “DNSMASQ_LISTENING” sorry.
20/02/2025
Had a rethink of the Guide, and it has been rewritten to include an overdue request of including Unbound!24/02/2025
Historic Updates

What is Pi-hole?

If you are looking to get advertising and tracking blocked across all the devices on your network a Pi-hole will have you covered. It’s a locally hosted Domain Name Server and uses block lists to stop adverts.

This guide will get you set up with Pi-hole and cover some basic initial settings, I recommend checking out the documentation for all the various features available.

Pi-hole GitHub

What is Unbound (Optional)

Unbound is a validating, recursive, caching DNS resolver. Rather than using an upstream DNS provider such as Google or Cloudflare who will look up the IP addresses for domain names you visit Unbound does this for you. It queries root servers for the address for a website. For example when you visited this site its actually on the server 213.186.33.50. This adds a layer of privacy in your web browsing as you are not relying on a third party with this information.

Unbound GitHub

Host vs Bridge vs Macvlan Network Modes

You need to decide which mode of Networking you want to use, I have outlined the key points below in general order of preference. (Unbound will be on a bridge which has no impact on your choice)

Host:

Host mode uses your NAS underlying network to run the containers network services, so it will be reliant on the NAS not using any of the required ports for the container. However, this makes it easy to set up, but you need to make sure no other service is using the required ports. All your clients will appear correctly as independent devices and stats.

Bridge Mode:

The main benefit of Bridge Mode will be the ease of setup however you will find that all clients on your network will appear under the same IP as the Bridge 172.20.0.1. This won’t impact ad blocking, but it will mean you can apply device specific rules etc.

Macvlan:

This gives you the benefit of Pi-hole having its own IP address on your network, all clients appear with their real IP addresses allowing you to assign specific rules and give you some nicer stats. However, one downside is that your NAS will not be able to use Pi-hole for DNS, due to the additional security features of Macvlan and its communication with its host. This is generally not an issue unless you wanted to use your Ad blocking with Tailscale.

Please note you will not be able to use Macvlan with a Bonded network connection e.g. ‘Bond0’. You will need to remove the bond in order to use this method.

Let’s Begin

In order for you to successfully use this guide you will need to check that your Router allows you to change your network DNS servers, this is usually found in the DHCP settings.

Please follow the initial guide below to get a restricted Docker user set up, then come back here.

Folder Setup

Let’s start by getting some folders set up for the container to use. Open up File Station create the following.

Folders
/docker/projects/pihole-compose
/docker/pihole
/docker/unbound #Optional

Unbound Configuration (Optional)

We need to make a config file for Unbound to define its network settings.

Download the file below and put it into the “unbound” folder we created earlier

Container Manager

Next we are going to set up a ‘Project’ in Container Manager. Open up Container Manager and click on Project then on the right-hand side click ‘Create’.

In the next screen we will set up our General Settings, enter the following:

SectionSetting
Project Name:pihole
Path:/docker/projects/pihole-compose
Source:Create docker-compose.yml

The code section of the below will be blank until we move to the next step.

Next we are going to drop in our docker compose configuration. You now need to decide if you are going to go with Host, Bridge Mode or Macvlan. Jump to the appropriate page to follow the setup.

Host – Page 2
Bridge – Page 3
Macvlan – Page 4

Pages: 1 2 3 4 5

Published inAd-Blocking / DNS 7.2DockerSynology

167 Comments

  1. chris chris

    hi, just discovered your site, it is amazing !

    I ‘m using talescale with my synology, and I have the following message :
    Code d’erreur : PR_END_OF_FILE_ERROR

    I connect to : tailscaleIPAdress:8000/admin/login.php

    • Dr_Frankenstein Dr_Frankenstein

      Hey thanks 🙂

      The machine you are on is it connected to Tailscale – Do you have subnetting enabled as you can then just use the NAS IP instead of the tailscale one

  2. RJ RJ

    Have you tried using this with Unbound? Do you have one in the works that combines Pihole with Unbound?

    • Dr_Frankenstein Dr_Frankenstein

      I did have unbound running a few years ago on my original PiZero install – Let me check what it entails for Docker.

  3. Jesús P Jesús P

    Thank you for this guide. I have followed the whole guide and when I click “done” I get the error “Start container pihole failed: {“message”: “driver failed programming external connectivity on endpoint pihole: error starting useland proxy: listen tcp4 0.0.0.0:53: bind: address already in use”}

    I tried a “netstat” and it does not indicate any other open processes on port 53

    Can you help me.

    Thank you

    • Dr_Frankenstein Dr_Frankenstein

      Hey – can you try changing the network mode to host – you will need to review the ‘ports’ section.

      network_mode: host

      Try changing the ports section to include ‘udp’

      – 53:53/udp

  4. Roger Roger

    Hi, thanks for this guide.

    I want to see the device names in the Pihole statistics. Your last sentence states “Also note as we are not using Pi-hole as the DHCP server you will not be able to see the names of the devices in the statistics just their IP addresses.”

    Can you advise.

    • Dr_Frankenstein Dr_Frankenstein

      So there is an option within the UI Settings > DNS > Conditional Forwarding, you will need to set the IPs as described in the info, I never managed to get this to function on my own network.

      Local network in CIDR notation = Basically take your NAS IP and change the last number to 0 (e.g 192.168.0.101 would be 192.168.0.0)
      IP address of your DHCP server (router) = Your Router IP

  5. Max Max

    Hello there, thanks for putting this together! The pihole container image downloads, it gets created with all my settings, but I can not load the pihole login page.

    When I check the log (container manager>container>log), I see the following repeating error message:

    lighttpd: no process found
    Stopping lighttpd
    pihole-FTL: no process found
    Stopping pihole-FTL
    (repeat, repeat, repeat)

    I followed steps 1,2,3 from your “initial setup” pages before I created the container… not sure what I missed. I will try again later this week but I wonder if these error messages immediately show that I missed a specific step?

    • Dr_Frankenstein Dr_Frankenstein

      Check to make sure your PUID/PGID (UID/GID)are correct in case it is struggling to write the config into /docker/pihole

      • Max Max

        Hi Doctor, thanks for the fast response! I think my GUI and UID are correctly set (see below). I did a bunch of Googling of similar issues, and here’s what I changed in the YAML file to get it to work.

        (change #1) I changed DNSMASQ user from pihole to root:
        DNSMASQ_USER=root

        (change #2) I commented out the 4 lines requiring UID/GID:
        # – PIHOLE_UID=1033
        # – PIHOLE_GID=100
        # – WEB_UID=1033
        # – WEB_GID=100

        I don’t know what’s going on under the hood, but this is what worked for me. Do you think I’m doing something particularly stupid/insecure with these changes?

        • Dr_Frankenstein Dr_Frankenstein

          I suspect it’s a permission issue as removing those lines and changing to root means all the files are owned by the root user in the container. So has exclusive permissions to the mounted folder.

        • Daniel Daniel

          Hey Max,

          I have run into this exact same issue. Were you able to fix the permissions issue at all? If so, are you able to share the resolution steps?

          Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

drfrankenstein.co.uk – writing Synology Docker Guides since 2016 – Join My Discord!