Installing PiHole via Portainer

Installing PiHole via Portainer

PiHole is a DNS based ad filter for your home network. As applications (usually via web browser) request ads to display, they will be passed through PiHole which will filter requests to known ad servers. Since these requests will not be sent, you will not receive ads. This not only improves your experience from not being served ads, but will actually speed up some web pages.

In order to get started, you should already have docker and portainer setup. You can follow the directions here if you haven’t set them up yet.

Download the Image

First, log into portainer (using your NAS credentials) which should be located at:

http://${your synology address}:9000

Locate the images tab in the menu

In the Pull image section add pihole/pihole:latest

You should see the image in the images section below

Setup the Local Filesystem

You’ll need to make some directories so that the PiHole container can store data. Make the following directories (via File Station or SSH in and make them via command line)


Initialize the Container

Switch back to portainer and click on the Containers tab on the menu

Click on Add container

In the Name field type pihole.

In the Image configuration section type pihole/pihole:latest (you should get an autocomplete box, since its already in the image repository)

Make sure that

  • Always pull the image is checked
  • Publish all exposed network ports to random host ports is unchecked

Map the Ports

Scroll down to Manual network port publishing and create the following entries:

Map the Volumes

Scroll down to Advanced container settings and click on the Volumes tab

Create the following entries by clicking on map additional volume, then select the Bind button and then typing in these entries

(Adding as a code block here for easy copy/paste)

/etc/pihole -> /volume1/docker/pihole/pihole
/etc/dnsmasq.d -> /volume1/docker/pihole/dnsmasq.d

Container Permissions

Click on the Restart policy tab and choose the Unless Stopped button

Click on the Runtime & Resources tab and check the Privileged mode slider

Environment Variables

Open the Env tab and enter the following key/value pairs

TZAmerica/Denver (or whatever is appropriate for your location)
Optional, but makes the blacklist get updated at midnight at your correct timezone

You can also set the DNS to the CloudFlare DNS servers


Deploy the Container

Now scroll up a bit and locate the Deploy the container button above the Advanced container settings section and click it.

Login to PiHole the First Time

You should be able to login to your PiHole admin screen now at

http://${your nas ip address}:18080/admin/index.php

Pay attention to the note at the bottom:

After installing Pi-hole for the first time, a password is generated and displayed to the user.

We’re going to get the password from the container logs. Go back to portainer’s container view and click on pihole container. Click the logs link.

You should see a line that looks like

Setting password: yVLDHx-O

Copy this password and use it to log into the pihole admin screen. Before we move on, lets update the password

Change the Admin Password

Go to the pihole container screen again and instead of going to logs, use the console link.

Click the connect button

This should give you a bash shell on the virtual instance that pihole is running on. Use this command to set a password

# pihole -a -p
Enter New Password (Blank for no password): 
Confirm Password: 
  [✓] New password set

Update the DNS on Your Router

You’ll need to update your router to drive all DNS traffic through to your pihole instance. The instructions for how to do this are different for all of the router vendors firmware. I’m using DD-WRT though, so you manage that via the Setup/Basic Setup tab in the Network Address Server Settings (DHCP) section

Make sure that you have a backup DNS in case pihole is unavailable. are the cloudflare DNS servers and are the pihole fallback DNS servers as well.

Testing It Out

Finally, lets test it out. This site has a good way to check if multiple ways of serving ads are being blocked.

0 comments on “Installing PiHole via PortainerAdd yours →

Leave a Reply

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