Install Pi-Hole as a Docker container using Portainer

Pi-hole is a network-level ad blocker and internet tracker blocker that can be installed on a Raspberry Pi or other compatible devices. This guide explains how to setup Pi-Hole as a Docker container through the Portainer system.

This will be installed as a container onto Docker running on an OpenMediaVault server

It also requires Portainer

Create a new Docker MACVLAN adapter

A Macvlan is a type of network driver in Docker that allows a container to be directly attached to a physical network interface on the host system. This provides the container with its own MAC address and allows it to appear as a separate physical device on the network.

Logon to the OpenMediaVault server using SSH and note down the name of the network adapter using on the LAN. Typically if wired this will be eth0 but double check.

ifconfig

Now, you need to determine the network design you’re system is running in. You’ll need the following data values

DataValue
Network card nameeth0
Subnet192.169.1.0/24
Gateway192.168.1.254
New IP for Pi-Hole192.168.1.95/32
Network namegrinntec-net

Execute this command in the SSH session substituting the values with your own.

sudo docker network create -d macvlan -o parent=`eth0` --subnet=`192.168.1.0/24` --gateway=`192.168.1.254` --ip-range=`192.168.1.95/32 grinntec-net`

Create Volumes

In Portainer and the local Docker environment goto Volumes and add two volumes:

etc-pihole

etc-dnsmasq.d

image

Create container

Under Containers add a new Container and give it a name of Pi-Hole and for the Image path enter pihole/pihole:latest.

image

Add five Manual network port publishing ports as below

HostContainerProtocol
5353UDP
6767UDp
8080TCP
44344TCP
5353TCP
image

Under the Volunessections create two new volumne mounts.

ContainerTypeVolume
/etc/piholeVolunmeetc-pihole - local
/etc/dnsmasq.dVolumneetc-dnsmasq.d - local
image

Under the Network section select the MACVLAN adapater created earlier.

image

Under the Env section add two new environment variables.

NameValue
WEBPASSWORDEnter a password that will be used to logon to the Pi-Hole service
ServerIPEnter the IP address you used on the MACVLAN setting
image

Under the Restart Policy section set it to Always.

image

Under the Capabilitiesenabled Net Admin.

image

Click Deploy Container

Once the container is running you can logon to the web portal using the IP you configured on the MACVLAN.

image

References

How to Install Pi-Hole on OpenMediaValut

Last modified July 21, 2024: update (e2ae86c)