Skip to content

Instantly share code, notes, and snippets.

@stvhay
Last active March 3, 2020 15:00
Show Gist options
  • Save stvhay/805412a1e7d9907ca218de2b40aee043 to your computer and use it in GitHub Desktop.
Save stvhay/805412a1e7d9907ca218de2b40aee043 to your computer and use it in GitHub Desktop.
Pi Hole Docker Notes

/etc/systemd/network/net0_dns0.netdev

[NetDev]
Description=Virtual device for PiHole DNS
Name=dns0
Kind=macvlan

[MACVLAN]
Mode=bridge

/etc/systemd/network/net0_dns0.network

[Match]
Name=dns0

[Link]
MACAddress=36:95:24:b0:b3:99

[Network]
DHCP=ipv4

Modify the docker run script

#!/bin/bash

# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md

docker run -d \
    --name pihole \
    -p 192.168.2.10:53:53/tcp \
    -p 192.168.2.10:53:53/udp \
    -p 192.168.2.10:80:80 \
    -p 192.168.2.10:443:443 \
    -e TZ="America/Chicago" \
    -v "$(pwd)/etc-pihole/:/etc/pihole/" \
    -v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
    --dns=127.0.0.1 --dns=1.1.1.1 \
    --restart=unless-stopped \
    pihole/pihole:latest

printf 'Starting up pihole container '
for i in $(seq 1 20); do
    if [ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" == "healthy" ] ; then
        printf ' OK'
        echo -e "\n$(docker logs pihole 2> /dev/null | grep 'password:') for your pi-hole: https://${IP}/admin/"
        exit 0
    else
        sleep 3
        printf '.'
    fi

    if [ $i -eq 20 ] ; then
        echo -e "\nTimed out waiting for Pi-hole start, consult check your container logs for more info (\`docker logs pihole\`)"
        exit 1
    fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment