Synology: Install Pi-hole With Portainer

Synology Install Pi-hole With Portainer

My previous guide for Pi-hole involved the use of Task Scheduler. Today I’m offering a recommended and excellent alternative for installing the latest Pi-hole version via Portainer. Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole and optionally a DHCP server, intended for use on a private network. In this step by step guide I will show you how to install Pi-hole on your Synology NAS using Docker & Portainer.

💡Note: This guide works perfectly with the latest version of Pi-Hole v5.17.3 and DSM 7.2.1

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.

  • STEP 3

Add Google DNS. Go to Control Panel / Network / General. Check “Manually configure DNS server” and add on Preferred DNS Server: 8.8.8.8 and on Alternative DNS Server: 8.8.4.4 Click Apply. Follow the instructions in the image below.

Pi-hole Synology NAS Portainer Set up 1

  • STEP 4

Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it pihole. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Pi-hole Synology NAS Portainer Set up 2

  • STEP 5

Now create two new folders inside the pihole folder that you previously created at STEP 4 and name them dnsmasq.d and pihole. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Pi-hole Synology NAS Portainer Set up 3

  • STEP 6

Log into Portainer using your username and password. On the left sidebar in Portainer, click on Stacks then + Add stack. Follow the instructions in the image below.

1 Synology Portainer Add Stack

  • STEP 7

In the Name field type in pihole. Follow the instructions in the image below.

Note: Copy Paste the code below in the Portainer Stacks Web editor.

version: "3.9"
services:
  pihole:
    image: pihole/pihole
    container_name: Pi-Hole
    mem_limit: 2g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:false
    restart: on-failure:5
    network_mode: host
    volumes:
      - /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d:rw
      - /volume1/docker/pihole/pihole:/etc/pihole:rw
    environment:
      WEB_PORT: 8080
      WEBPASSWORD: mariushosting
      WEB_BIND_ADDR: 192.168.1.18
      TZ: Europe/Bucharest
      DNSMASQ_USER: root
      DNSMASQ_LISTENING: local

Note: Before you paste the code above in the Web editor area below, change the value for WEBPASSWORD and add your own password. mariushosting is an example for a password, you should use your own password.
Note: Before you paste the code above in the Web editor area below, change the value for WEB_BIND_ADDR and add your own Synology NAS Local LAN IP. 192.168.1.18 is my NAS local LAN IP, you should use your own NAS local LAN IP.
Note: Before you paste the code above in the Web editor area below, change the value for TZ. (Select your current Time Zone from this list.)

Pi-hole Synology NAS Portainer Set up 4 new 2024

  • STEP 8

Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.

Pi-hole Synology NAS Portainer Set up 5

  • STEP 9

If everything goes right, you will see the following message at the top right of your screen: “Success Stack successfully deployed“.

Pi-hole Synology NAS Portainer Set up 6

  • STEP 10

Go back to STEP 1 or you will deal with karma 🙂

  • STEP 11

The installation process can take up to a few seconds/minutes. It will depend on your Internet speed connection. Now open your browser and type in http://Synology-ip-address:8080/admin/login.php Type in the password you have previously created at STEP 7. Click Log in. Follow the instructions in the image below.

Pi-hole Synology NAS Portainer Set up 7

  • STEP 12

Your Pi-hole dashboard at a glance!

Pi-hole Synology NAS Portainer Set up 8 5.17.3

Note: Many content providers (like YouTube / Reddit / Twitch / Spotify / Pandora / Facebook / Hulu) now stream/serve ads from the same servers as the content (meaning if you attempt to block the ads using a Pi-Hole you will also block the content). If you want to view YouTube without Adverts content, just use Piped or Invidious.
Note: Use Pi-Hole As DNS on Windows 11.
Note: How to Activate Dark Mode in Pi-Hole.
Note: How to Free Disk Space on Your NAS If You Run Docker.
Note: Some people may have problems launching Pi-Hole via Docker. This may be because of different settings in your Synology NAS and router. Every user has their own router settings etc. It’s really hard to troubleshoot the problem. You can also contact me via email and I will try to find a personalized solution for you.
Note: After installing Pi-hole (through Docker), Synology NAS drives are not hibernating at all. The best solution is to Disable Hibernation. This will be easier and much more beneficial overall for everything Pi-hole needs to read database of filters.
Note: Find out how to update Pi-Hole container with the latest image.

Fix: Pihole 403 Forbidden. If you want to use Pi-Hole with Synology Reverse Proxy, add your DDNS like you did until now, with WebSocket, then access Pi-Hole in your browser using pihole.yourname.synology.me/admin/login.php At the end of your own domain name or DDNS just add /admin/login.php
Fix: If someone has a problem once installation is completed, and gets an error like “This site can’t be reached“, open the Pi-hole GUI and go to Settings / DNS tab and in “Interface listening behavior” change to Listen on all interfaces instead of Listen only on interface eth0. (Reported by jtd).
Fix: If your Pi-hole container keeps disconnecting, uninstall the Synology Package named “DNS Server” or “DHCP Server” which conflicts with Pi-hole on port 53 and doesn’t let your Pi-hole start.
Fix: If your Pi-hole container gets a DNS service not running, uninstall the Synology Package named “DNS Server” or “DHCP Server” which conflicts with Pi-hole on port 53 and doesn’t let your DNS work.
Fix: If you experience connections problems, remember to set your Synology Firewall in Control Panel / Security / Firewall / Edit Rules / Create Firewall Rules and allow Custom Port 53 Protocol All.
Fix: If you can’t play videos from CNN, in the PiHole whitelist add the following address: c.amazon-adsystem.com
Fix: How can I make Pi-Hole work over VPN connection? Go to Pi-Hole / Settings / DNS tab / Interface Settings / choose Permit all origins the scroll down the page all the way and click Save. Follow the instructions in the image below.

Pihole Synology Portainer VPN permit all origins
Fix: If you want to run the DHCP server on docker with pi-hole, just add the cap_add: NET_ADMIN directive as per the instructions below.

version: "3.9"
services:
  pihole:
    image: pihole/pihole
    container_name: Pi-Hole
    mem_limit: 2g
    cpu_shares: 768
    security_opt:
      - no-new-privileges:false
    restart: on-failure:5
    network_mode: host
    cap_add:
      - NET_ADMIN
    volumes:
      - /volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d:rw
      - /volume1/docker/pihole/pihole:/etc/pihole:rw
    environment:
      WEB_PORT: 8080
      WEBPASSWORD: mariushosting
      WEB_BIND_ADDR: 192.168.1.18
      TZ: Europe/Bucharest
      DNSMASQ_USER: root
      DNSMASQ_LISTENING: local

Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: At STEP 7, you can also change the value variable for the: WEB_PORT – 8080 to 1010 or whatever you want.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Saturday / February 24th, 2024 at 6:37 AM