{"id":100,"date":"2023-08-05T08:00:21","date_gmt":"2023-08-05T08:00:21","guid":{"rendered":"http:\/\/it4home.dk\/?p=100"},"modified":"2023-11-18T14:19:24","modified_gmt":"2023-11-18T12:19:24","slug":"setting-up-pi-hole-with-docker-for-network-wide-ad-blocking","status":"publish","type":"post","link":"https:\/\/it4home.dk\/index.php\/2023\/08\/05\/setting-up-pi-hole-with-docker-for-network-wide-ad-blocking\/","title":{"rendered":"Setting Up Pi-hole with Docker for Network-Wide Ad Blocking"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/100?print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><\/a><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/100?print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"https:\/\/it4home.dk\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">Introduction:<br>Pi-hole is a popular network-level ad blocker that helps you block advertisements at the DNS level. With Docker, you can easily deploy Pi-hole on your network for ad-free browsing on all your connected devices. In this guide, we&#8217;ll walk you through the process of setting up Pi-hole using Docker.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 1: Install Pi-hole with Docker<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install Pi-hole and run it in Docker, execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d --name=pihole \\\n  -e TZ=Europe\/Copenhagen \\\n  -e WEBPASSWORD=xxxxxxx \\\n  -e SERVERIP=192.168.0.224 \\\n  -e FTLCONF_LOCAL_IPV4=192.168.0.227 \\\n  -v pihole_data:\/etc\/pihole \\\n  -v pihole_dnsmasq:\/etc\/dnsmasq.d \\\n  -p 81:80 \\\n  -p 53:53\/tcp \\\n  -p 53:53\/udp \\\n  --net=host \\\n  --restart=unless-stopped \\\n  pihole\/pihole:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Explanation of options used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-d<\/code>: Run the container in the background (detached mode).<\/li>\n\n\n\n<li><code>--name=pihole<\/code>: Assign the name &#8220;pihole&#8221; to the container for easy management.<\/li>\n\n\n\n<li><code>-e TZ=Europe\/Copenhagen<\/code>: Set the timezone to &#8220;Europe\/Copenhagen&#8221; inside the container.<\/li>\n\n\n\n<li><code>-e WEBPASSWORD=xxxxxxx<\/code>: Set a custom web admin password for Pi-hole. Replace &#8220;xxxxxxx&#8221; with your desired password.<\/li>\n\n\n\n<li><code>-e SERVERIP=192.168.0.224<\/code>: Set the IP address of the Docker host (Raspberry Pi) where Pi-hole will run. Replace &#8220;192.168.0.224&#8221; with your Raspberry Pi&#8217;s IP address.<\/li>\n\n\n\n<li><code>-v pihole_data:\/etc\/pihole<\/code>: Create a Docker volume named &#8220;pihole_data&#8221; and mount it to the &#8220;\/etc\/pihole&#8221; directory inside the container. This volume allows you to persist Pi-hole&#8217;s data and configurations.<\/li>\n\n\n\n<li><code>-v pihole_dnsmasq:\/etc\/dnsmasq.d<\/code>: Create a Docker volume named &#8220;pihole_dnsmasq&#8221; and mount it to the &#8220;\/etc\/dnsmasq.d&#8221; directory inside the container. This volume is used to customize DNS settings and blocklists.<\/li>\n\n\n\n<li><code>-p 81:80<\/code>: Map port 80 from the container to port 81 on the host system. This allows you to access Pi-hole&#8217;s web interface at <code>http:\/\/localhost:81<\/code>.<\/li>\n\n\n\n<li><code>-p 53:53\/tcp -p 53:53\/udp<\/code>: Map port 53 from the container to both TCP and UDP port 53 on the host system. This enables Pi-hole to handle DNS requests. Or &#8220;&#8211;net=host \\&#8221; for local network install.<\/li>\n\n\n\n<li><code>--restart=unless-stopped<\/code>: Configure the container to automatically restart if it stops unexpectedly.<\/li>\n\n\n\n<li><code>pihole\/pihole:v5.6<\/code>: Specifies the Docker image to use for running Pi-hole (version 5.6).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Step 2: Access Pi-hole Web Interface<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the Pi-hole container is up and running, open a web browser and navigate to <code>http:\/\/localhost:81<\/code>. You will be directed to Pi-hole&#8217;s web interface. Use the custom web admin password you set in the Docker command to log in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations! You have successfully deployed Pi-hole on your network using Docker. Your network devices will now benefit from network-wide ad blocking, providing a seamless and ad-free browsing experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to configure your devices to use your Raspberry Pi&#8217;s IP address (192.168.0.224) as the DNS server to take advantage of Pi-hole&#8217;s ad-blocking capabilities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enjoy ad-free browsing and network-level ad blocking with Pi-hole and Docker! Happy browsing!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:Pi-hole is a popular network-level ad blocker that helps you block advertisements at the DNS level. With Docker, you can easily deploy Pi-hole on your network for ad-free browsing on all your connected devices.&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":198,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2,34,11],"tags":[35],"class_list":["post-100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-privacy","category-security","tag-ok"],"_links":{"self":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":4,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":394,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions\/394"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media\/198"}],"wp:attachment":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}