ads by pixabay
ads by pixabay

Deploy PiHole in your NAS via Docker

If you read our post about compiling your own binaries for WD MyCloud OS5 where we explained how to install and use packages like Docker, you may want to deploy your first container.

Say you have installed any extension like uBlock in your browser that blocks all the ad crap from the websites you visit. Sometimes it is just not enough: you may not be able nor want to install browser extensions on mobile devices, or simply sometimes you don’t even have the chance to do so.

Friendly reminder: we maintain this site thanks to ads after all, maybe we’re shooting ourselves in our foot with this post though! It’s okay, we understand it, even support it.

Given that, you’ll need to change the scope of the solution. In this case, we propose stepping up from the browser level to the network, DNS level. That’s where we are focusing today, and yeah, we will make our NAS provide that feature!

Pre-checks

Before starting, have you tried to run the basic Docker command in your NAS? Remember you can do this by just connecting via SSH and typing:

$ docker -v
Docker version 20.10.12, build e91ed57

There we go, we have Docker available, ready to deploy a PiHole container to block almost every ad around the Internet.

Installing PiHole on Docker

At this point you can just visit our profile on GitLab and clone the wdmycloud-dockerfiles repository, where you can find a variety of software pieces ready to run on your MyCloud OS5 NAS.

$ git clone https://gitlab.vectops.com/aletz/wdmycloud-dockerfiles.git
$ cd wdmycloud-dockerfiles/pihole

Now, run this command and let the magic happen:

$ docker-compose up -d

It will:

  • Pull the PiHole Docker image in your NAS
  • Apply a basic configuration to fire up the container

After it finishes, you will be able to manage your Pihole through its web UI in the following URL: http://you_nas_ip:8080/admin.

Configuring your environment

From this panel you can configure lots of things to get PiHole working in your local network as you’d like to. Now it’s time to configure your network to start using your PiHole instance at a DNS configuration level. You have multiple ways to do:

  • Configure your DNS in DHCP Server on your main router
  • Configure each device with this custom DNS

I prefer configuring the DNS in the dhcp-server, so every device on my network uses DHCP protocol to get access to the Internet (and yes, it is possible to use "static IP addresses" with the dhcp-server lease option) and gets all the ads blocked by default with no extra effort.

After this step, you are done setting everything up and will start browsing ad-free from every device on your network!

Thank you for reading, I would be very pleased to know if this article helped you get a PiHole working on your local NAS!

See you next time. Don’t forget to share & leave a comment!