Logos Property of Pi-hole & Docker.

While I was disappearing down a rabbit hole investigating unbound as a DNS Privacy server, I came across Pi-hole – A black hole for Internet advertisements.

I’ve always used uBlock Origin for ad blocking but that is a per client thing which is a bit of a hassle.

Pi-hole provides ad blocking for all clients on the network, seamlessly. I just configure DNS on each client, via DHCP, to point towards the Pi-Hole server.

Obviously, I love Docker so it’s in a Docker Container on a Raspberry Pi.

Currently, I’ve sacrificed DNS privacy but I’ll work on that later in terms of getting Pi-hole to send all DNS queries through my own DNS server.

This is how I implemented it. Obviously, these aren’t detailed instructions but more of a reference to jog my memory if I need it!

# Note: Substitute the IP address of the host that the Container is running on for
# ${IP} and ${IPv6}  

docker run -d \\
    --name=pihole \\
    --hostname=pihole \\
    -p 53:53/tcp -p 53:53/udp -p 80:80 \\
    -e ServerIP="${IP}" \\
    -e ServerIPv6="${IPv6}" \\
    -v pihole\_data\_1:/etc/pihole/ \\
    -v pihole\_data\_2:/etc/dnsmasq.d/ \\
    --restart=unless-stopped \\
    pihole/pihole:v4.0\_armhf

Update 07/06/2024:

I would tend to do this with Docker Compose files these days. See below with all details here:

version: "3"

services:
  pihole:
    hostname: pihole
    container_name: pihole
    image: pihole/pihole:latest
    restart: unless-stopped
    volumes:
      - data_1:/etc/pihole/
      - data_2:/etc/dnsmasq.d/
    ports:
      - "8008:80/tcp"
      - "192.168.178.166:53:53/tcp"
      - "192.168.178.166:53:53/udp"
    environment:
      - IPv6=false
      - WEBPASSWORD=MY_STRONG_PASSWORD
    networks:
      net:
        ipv4_address: 10.0.0.3

volumes:
  data_1:
  data_2:

networks:
  net:
    driver: bridge
    ipam:
       config:
         - subnet: 10.0.0.0/24