Tired of being bombarded with ads every time you browse the internet or use a mobile app? Well, there's a fantastic solution called Pi-hole, which basically acts as a smart DNS filter . The best part is that you don't have to install anything on every device in your home; the system works from the core of your network, intercepting and blocking unwanted content before it even reaches your screen.
To set up this system, the smartest option today is to use Docker. By putting Pi-hole in a container, you avoid cluttering your computer's operating system, make updates incredibly easy, and get the most out of your hardware —whether it's a Raspberry Pi, an older server, or even a virtual machine running Ubuntu or Debian—without any service conflicts.
Prerequisites and site preparation
Before diving in, it's worth noting that Pi-hole is extremely lightweight. To run it smoothly, you only need about 512 MB of RAM and between 2 and 4 GB of disk space. As for the operating system, it works perfectly with distributions that use systemd or sysvinit, such as Debian, Ubuntu, Fedora, or Raspberry Pi OS.
A critical point is the network. For the system to be stable, Pi-hole requires a static IP address . If you don't want to bother configuring the server manually, you can reserve an IP address on your router so that it always assigns the same address to the computer hosting the container.
Deploying Pi-hole using Docker
The easiest way to set this up is through a docker-compose.yml file . This method allows you to define all the configuration at once. It's crucial to map the volumes (such as /etc/pihole and /etc-dnsmasq.d) to local folders on your host so that if you update the container image, you don't lose all your configurations or blacklists.
In the configuration file, pay attention to the ports. Port 53 is the heart of DNS and must be free. If you see that the container isn't starting, it's likely that systemd-resolved or dnsmasq is using that port on the host. In those cases, you'll need to disable the conflicting service or configure a bridge to redirect the traffic.
If you decide to use Pi-hole as a DHCP server as well, remember to add the NET_ADMIN capability in the cap_add section of compose and, preferably, use the host network mode (network_mode: host) to avoid connectivity issues.
Initial setup and access management
Once you execute the command docker-compose up -dThe system will be live. To access the control panel, connect to your server's IP address through the port you assigned (80 by default, although you can change it to 8080 or 89 to avoid conflicts with other web servers). If you didn't define a password in the environment variable... WEBPASSWORDThe system will generate a random one that you can find by checking the logs with the command docker logs pihole | grep random.
For added security, it's best to change that password quickly. You can access the container terminal using docker exec -it pihole /bin/bash and run the command pihole -a -p to set a password that is easy for you to remember but difficult for others.
Upstream Filtering and DNS Optimization
To ensure Pi-hole knows who to query when it doesn't recognize an address, you need to configure an upstream DNS server. A very robust option is Quad9 ; simply select its filtered servers (such as 9.9.9.9) in the DNS settings tab. This adds an extra layer of security and privacy to your browsing.
The heart of Pi-hole is its blocklists. If you want to start with something solid, you can add StevenBlack 's list . Whenever you modify the lists, whether by deleting entries with SQLite3 or adding new URLs, it's essential to go to Tools and run Update Gravity so that the database refreshes and the changes take effect.
Advanced tips: Local domains and management
If you have multiple services at home, you can create local domain names to avoid having to memorize IPs. To do this, create a file called local.list on the mounted Pi-hole volume, defining the IP and domain format. Then, create a configuration file for dnsmasq that references that list and restart the container.
To manage the system without accessing the website, there are very useful commands you can run from the host. For example, to add a domain to the blacklist, use `pihole -b mydomain.com` , or to temporarily disable filtering for 10 minutes, you can use `pihole disable 10m` , which is very handy when a legitimate website is mistakenly blocked.
Taking control of home advertising is entirely feasible by combining modest hardware with the flexibility of Docker, ensuring port 53 is clear, and properly configuring volumes to persist data. Once you've adjusted the DNS on your router and optimized the Gravity lists, you'll enjoy a cleaner and much faster network across all your devices.
