I was at the office a couple of weeks back, browsed some of my favorite news sites, and was shocked by what I saw. Ads, ads everywhere!
At home, I’ve been running Pi-hole on my Synology NAS in a container for months now. I hardly see any (annoying) advertisements on any of my devices because of this.
Now don’t get me wrong, I don’t mind seeing a couple of relevant ads. The thing that annoys me, though, is ads causing content to jump around on the page. Those ads are one of the reasons I’m running Pi-hole.
Being a developer, I have Docker installed on my desktop. Because of this, I can run Pi-hole in a container on my development laptop and set this container up as my local DNS.
While this is a bit more work than installing your adblocker of choice in a browser, it is more fun.
Creating the Pi-hole container
The most important part of this post is the following
It will create a new container for you based on the latest pi-hole image available. Then, the necessary ports are forwarded to/from the container, and I’m using Cloudflare as my public DNS.
You might want to change the
WEBPASSWORD to something else as
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" environment: TZ: 'Europe/Amsterdam' WEBPASSWORD: 'pihole' PIHOLE_DNS_: 220.127.116.11 # Volumes store your data between container upgrades volumes: - './etc-pihole/:/etc/pihole/' - './etc-dnsmasq.d/:/etc/dnsmasq.d/' # 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
To start the container, run the following command in the folder containing the file:
docker-compose up --detach.
After the container is booted, you can set up your DNS to
127.0.0.1, or navigate the administration panel
Setting the correct DNS in your network adapter(s) isn’t hard, but feels a lot like grunt work.
A tool I’ve been using is DNS Jumper. It makes switching the DNS a lot easier.
Safely install it using Chocolatey in an elevated prompt.
choco install dnsjumper
You are now able to switch DNS with a a couple of mouse clicks.