Skip to content

Instantly share code, notes, and snippets.

@sphrak
Last active March 30, 2023 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sphrak/9fe95564ee2407c46f9c0bafdb8a3187 to your computer and use it in GitHub Desktop.
Save sphrak/9fe95564ee2407c46f9c0bafdb8a3187 to your computer and use it in GitHub Desktop.
pihole

Deploy pihole in docker

  • pull
  • tear down
  • re-deploys pihole

Requirements

  • requires root to execute if docker daemon runs as root
#!/bin/bash

CID=$(docker ps -aqf "name=pihole")

docker pull pihole/pihole:latest
docker stop $CID
docker rm $CID
docker run -d \
    --name pihole \
    -p 53:53/tcp -p 53:53/udp \
    -p 1337:80 \
    -e TZ="Europe/Stockholm" \
    -v "/home/ubuntu/pihole/etc-pihole:/etc/pihole" \
    -v "/home/ubuntu/pihole/etc-dnsmasq.d:/etc/dnsmasq.d" \
    --dns=127.0.0.1 --dns=1.1.1.1 \
    --restart=unless-stopped \
    --hostname pi.hole \
    -e VIRTUAL_HOST="pi.hole" \
    -e PROXY_LOCATION="pi.hole" \
    -e FTLCONF_LOCAL_IPV4="127.0.0.1" \
    pihole/pihole:latest
docker ps

fixup

On ubuntu you will run into

Error starting userland proxy: listen tcp4 0.0.0.0:53: bind: address already in use.

This can be fixed by:

  • vim /etc/systemd/resolved.conf set DNSStubListener=no
  • sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
  • sudo systemctl restart systemd-resolved

reference: https://www.linuxuprising.com/2020/07/ubuntu-how-to-free-up-port-53-used-by.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment