Setting up Pi-hole in docker container using Docker for desktop

Recently in one of our session with Microsoft I came to know (even he shared statistics of blocked queries in his home setup) about Pi-hole and how it’s doing Ad blocking across all devices connected with a network. I was excited to try it out but main concern was to have a Raspberry Pi device. So I decided to try using Daemon (Docker for Desktop in Windows 10).

Setup went smoothly as it was expected (as I am using docker). Below are the step by step details:

1. First of all I spin up Daemon with Linux container (mostly I am keeping it off and not loading on windows startup).

2. Downloaded pi-hole docker image from docker hub using below command (use command window as Administrator)

docker pull pihole/pihole

3. Created below listed folders under Documents

      pi-hole-config

                pihole

                dnsmasq.d

4. After replacing some values in Docker Run command:

docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 8080:80 -p 8081:443 -v "/c/Users/rajneeshk/Documents/pi-hole-config/pihole/:/etc/pihole/" -v "/c/Users/rajneeshk/Documents/pi-hole-config/dnsmasq.d/:/etc/dnsmasq.d/" -e ServerIP="192.168.1.15" -e WEBPASSWORD=admin --restart=unless-stopped pihole/pihole:latest

5. Values to be replaces as per environment

    a) Port (http/https): I have used 8080 & 8081 (just to avoid any collision)

    b) Folder location(s), created in step 3.

    c) ServerIP: IP of the computer you are trying (for me it was 192.168.1.15)

    d) WEBPASSWORD: password to access web portal (I used default as this was experimental purpose only).

6. Output of the command is as below:

Setting up Pi-hole in container using Docker for desktop

Setting up Pi-hole in container using Docker for desktop

7. Did browse the url : http://192.168.1.15:8080/admin & it’s working  ðŸ˜Š

Now we need to setup Router DNS to flow traffic through pi-hole, here again I don’t want to touch the router (Frankly I don’t have access ☹). So decided to change DNS value to consumers (my laptop & tv)

1. Updated DNS in Laptop:

    a) Go to the Control Panel

    b) Click Network and Internet > Network and Sharing Center > Change adapter settings

    c) Select the connection for which you want to configure

    d) Right-click Local Area Connection > Properties

    e) Select the Networking tab

    f) Select Internet Protocol Version 4 (TCP/IPv4) or Internet Protocol Version 6 (TCP/IPv6)

    g) Click Properties

    h) Click Advanced

    i) Select the DNS tab

    j) Click OK

    k) Select Use the following DNS server addresses

    l) Replce those addresses with the IP addresses of your Pi (in my case its 192.168.1.15)

2. Same way I have updated to my LG TV

    a) Refer link for instruction

Now all setup is done and the time to see in action, refreshed the portal and saw 2 devices are connected and it was surprising that almost 15% of queries are getting blocked, Have a look.

Setting up Pi-hole in container using Docker for desktop

Setting up Pi-hole in container using Docker for desktop


2 Comments

  • Gravatar Image

    Hello, thank you for helpful guide. I have settled up pihole as well through docker. But only for laptop not for whole network.

    What all adlists/blocklists you use for India

  • Gravatar Image

    i am getting this error

    "docker: Error response from daemon: Ports are not available: listen udp 0.0.0.0:53: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."

    after using :

    docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 8080:80 -p 8081:443 -v "C:\Users\Raghav Swami\Documents\pi-hole-config\pihole/:/etc/pihole/" -v "C:\Users\Raghav Swami\Documents\pi-hole-config\dnsmasq.d/:/etc/dnsmasq.d/" -e ServerIP="192.168.0.129" -e WEBPASSWORD=admin --restart=unless-stopped pihole/pihole:latest


    please help me with this i am not able to find any solution to this.

Add a Comment