{"id":187,"date":"2021-12-21T21:42:00","date_gmt":"2021-12-21T20:42:00","guid":{"rendered":"http:\/\/pieter.wigleven.com\/it\/?p=187"},"modified":"2021-12-21T22:21:43","modified_gmt":"2021-12-21T21:21:43","slug":"automating-pi-hole-updates-with-addlist-customization-on-windows","status":"publish","type":"post","link":"https:\/\/pieter.wigleven.com\/it\/archives\/187","title":{"rendered":"Automating Pi-hole updates with addlist customization on Windows with Docker"},"content":{"rendered":"\n<p>Looking for a way to automate pi-hole updates with custom addlist entries, on Windows using Docker? Here&#8217;s what I did:<\/p>\n\n\n\n<p>Pre-reqs:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.docker.com\/products\/docker-desktop\" target=\"_blank\">Download Docker for Windows<\/a> and install<\/li><li>Create a new batch file, e.g. &#8220;update_pihole.bat&#8221; with the content below<ul><li>Change the <strong>docker run parameters<\/strong>, e.g. change the server IP\/password\/TimeZone\/DNS2 and DNS3 (leave DNS1 to the default 127.17.0.1)<\/li><li>Create a scheduled task on the Windows host that runs the script periodically, e.g. every month. Test the task to see if it&#8217;s working.<\/li><\/ul><\/li><li>Make sure the host can resolve DNS to download the latest pi-hole container after the script stops the running pi-hole docker container. I&#8217;ve configured a secondary DNS on my Windows host to point at my ISP&#8217;s DNS server directly.<\/li><li>Change your router&#8217;s DHCP to hand out IP&#8217;s with the DNS pointing to your Windows host\/pi-hole&#8217;s IP.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@echo off\nREM Update a pi-hole container on Windows using Docker and adding a bunch of custom addlists \nREM Latest script can be found on https:\/\/pieter.wigleven.com\/it\/archives\/187\n\nREM Stop and delete existing pi-hole container\ndocker stop pihole\ndocker rm pihole\n\nREM Clear out the Docker cache and all unused images (i.e. the out of date version of pi-hole).\ndocker image prune -a --force\n\nREM Pull latest pihole container, make sure your host can resolve DNS at this point!\ndocker pull pihole\/pihole\n\nREM Run pihole with customized parameters (change this to match your environment)\ndocker run -d --name pihole -e <strong>ServerIP=192.168.1.5 -e WEBPASSWORD=abcdefgh -e TZ=Europe\/Amsterdam -e DNS1=127.17.0.1 -e DNS2=8.8.8.8 -e DNS3=1.1.1.1<\/strong> -p 80:80 -p 53:53\/tcp -p 53:53\/udp -p 443:443 --restart=unless-stopped pihole\/pihole:latest\n\nREM Add custom addlist by modifying the database (ugly but only method AFAIK...)\ndocker exec pihole sqlite3 \/etc\/pihole\/gravity.db \"INSERT INTO adlist (address, enabled, comment) VALUES ('https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_tracking.txt', 1, 'comment');\"\ndocker exec pihole sqlite3 \/etc\/pihole\/gravity.db  \"INSERT INTO adlist (address, enabled, comment) VALUES ('https:\/\/s3.amazonaws.com\/lists.disconnect.me\/simple_ad.txt', 1, 'comment');\"\ndocker exec pihole sqlite3 \/etc\/pihole\/gravity.db  \"INSERT INTO adlist (address, enabled, comment) VALUES ('https:\/\/dbl.oisd.nl\/', 1, 'comment');\"\ndocker exec pihole sqlite3 \/etc\/pihole\/gravity.db  \"INSERT INTO adlist (address, enabled, comment) VALUES ('https:\/\/raw.githubusercontent.com\/PolishFiltersTeam\/KADhosts\/master\/KADhosts.txt', 1, 'comment');\"\n\nREM Update Gravity to download contents of custom addlists\ndocker exec pihole pihole updateGravity\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Consider leaving a reply if you found this to be helpful<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking for a way to automate pi-hole updates with custom addlist entries, on Windows using Docker? Here&#8217;s what I did: Pre-reqs: Download Docker for Windows and install Create a new batch file, e.g. &#8220;update_pihole.bat&#8221; with the content below Change the docker run parameters, e.g. change the server IP\/password\/TimeZone\/DNS2 and DNS3 (leave DNS1 to the default [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":15,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/posts\/187\/revisions\/204"}],"wp:attachment":[{"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pieter.wigleven.com\/it\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}