How to Install Pi-Hole on OpenMediaVault 5 inside Docker with Portainer using Raspberry Pi 4

In this segment, we are going to show you how to configure “Pi-Hole on Docker with Portainer using OpenMediaVault 5 Raspberry Pi 4 

What is OpenMediaVault?

OpenMediaVault (OMV) is a free Linux distribution designed for network-attached storage (NAS). The project’s lead developer is Volker Theile, who instituted it in 2009. OMV is based on the Debian operating system and is licensed through the GNU General Public License v3.

Source /> Wikipedia

OpenMediaVault

What is Pi-Hole?

pihole

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. It is designed for use on embedded devices with network capability, such as the Raspberry Pi, but it can be used on other machines running Linux and cloud implementations. Pi-hole can block traditional website adverts as well as adverts in unconventional places, such as smart TVs and mobile operating system adverts.

 

OpenMediaVault Versions :

OpenMediaVault 5 Installation Guide :

https://pcmac.biz/openmediavault-5-on-raspberry-pi/

Software Required :

Equipment Required Optional
Raspberry Pi Raspberry Pi 4 Case
SD_Card SD Card Keyboard
Ethernet Ethernet Cable Mouse
Charger Power Adapter    
HDD External HDD    
Buy Now

You can Buy Raspberry Pi 4 Kit from here

Pi-Hole

Checkout official website: pi-hole

Docker-compose

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'Asia/Kolkata'
      # WEBPASSWORD: 'set a secure password here or it will be random'
    # Volumes store your data between container upgrades
    volumes:
       - './etc-pihole/:/etc/pihole/'
       - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    dns:
      - 127.0.0.1
      - 1.1.1.1
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

Note: Please change the OMV default port from 80 to something else and then start with

sudo apt update
sudo apt dist-upgrade

Configuring Openmediavault Network Interface

  • First, we need to configure our DNS servers from Openmediavault Network Interface. Here we need to navigate to Network –> Interfaces and edit the Network.
  • However, we need to configure the DNS Server from Advanced settings to 127.0.0.1 or 1.1.1.1 as shown in Pi-Hole Docker-compose.
OpenMediaVault

Create Macvlan Network for Pi-Hole

  • Once the DNS is successfully configured then we need to open Putty and login to our OpenMediaVault with root user.
  • After that, enter the below-given command to create Macvlan network for Pi-Hole. Remember to change the subnet to your OpenMediaVault IP Address.
docker network create -d macvlan \
    --subnet=192.168.1.10/24 \
    --gateway=192.168.1.1 \
    -o parent=eth0 pub_net

Configure Pi-Hole container

  • Now, to pull the image we need to search for Pi-Hole container from the image box.
  • And look for the latest pihole/pihole:latest image and click on pull the image to download the latest pihole image.

OpenMediaVaultClick to ZOOM

  • Once the image is successfully downloaded then we need to navigate to Containers and then click on Add container.
  • After that, fill the details as mentioned below in the picture, Choose a name for your container and image name as pihole/pihole:latest.

Note: If you came across Port 53 bind error use the below-given command.

sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved

Pi-Hole

PiholeClick to ZOOM

  • In the volume section, we need to configure the path for /etc/pihole/, and /etc/dnsmasq.d/ folders then bind these folders to our desired path.

Pi-HoleClick to ZOOM

  • In the network section, use the below-given instructions to configure the container.
Network: Select the Macvlan network that we have created 
Hostname: Create a Host Name for your Pi-Hole 
IPv4 Address: Type an IP Address for your Pi-Hole
Primary DNS: 127.0.0.1
Secondary DNS: 1.1.1.1

Pi-HoleClick to ZOOM

  • After that, we need to configure Environment Variables as mentioned below in the picture.
ServerIP : "Type the Pi-Hole IP Address, which we created" 
TZ: "Asia/kolkata", Type your Time Zone 
WEBPASSWORD : "Password of your choice"

Pi-HoleClick to ZOOM

  • In this section we need to select unless stopped.

wordpressClick to Zoom

  • In this section, we need to enable NET_ADMIN from the list.

Pi-Hole

Click to Zoom

  • Finally, once everything is done we can go ahead and click on Deploy the container.
Pi-Hole

Access Pi-Hole Server Web Interface

  • To access the Pi-Hole web interface we need to type the Pi-Hole IP Address/admin.
  • Besides, our Pi-Hole is not yet ready for blocking Ads on our Network. We need to update Pi-Hole IP Address to our Router DNS.
Pi-Hole
http://Pi-Hole IP Address/admin/

Updating Pi-Hole IP Address to Router DNS

  • At this moment we need to log in to our Router, then Navigate to DNS Settings.
  • After that, we need to enter the Pi-Hole IP Address to our Router Primary DNS Address.
  • Finally, all the traffic will route through the Raspberry Pi and Block ads with Pi-Hole.
Primary DNS Address   : "Pi-Hole IP Address"
Secondary DNS Address : "Cloudflare DNS Address i.e 1.1.1.1"
router DNS

Reset Pi-Hole Password

  • However, if you forgot the Pi-Hole password you can reset it anytime by using this command.
docker exec -it pihole pihole -a -p
In conclusion, you are all set to use Raspberry Pi 4 as Pi-Hole Network Wide Ad-Block Server. If you face any issue regarding this article please share your thoughts. Enjoy using Pi-Hole on Docker using Openmediavault. Smile (.”_”.)

Please check out my other articles:

Did you find us helpful?

Subscribe our YouTube Channel
Like us on Facebook facebook
Support us on Patreon Patreon
Share This Article with others

Harish Kumar

As a founder of the PcMac YouTube channel and website, Our goal is to provide Free Technical help to people and spread knowledge to everyone.
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments