Skip to content

Instantly share code, notes, and snippets.

@bt5e
Created April 27, 2019 01:42
Show Gist options
  • Save bt5e/a13cfc74ffc5f586b015ca5d8825f173 to your computer and use it in GitHub Desktop.
Save bt5e/a13cfc74ffc5f586b015ca5d8825f173 to your computer and use it in GitHub Desktop.
pi hole docker run script to support DHCP
#!/bin/bash
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md
docker run -d \
--name pihole \
--net=host \
-e TZ="UTC" \
-e ServerIP=10.0.0.101 \
-v "$(pwd)/etc-pihole/:/etc/pihole/" \
-v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
--dns=127.0.0.1 --dns=1.1.1.1 \
--cap-add=NET_ADMIN \
--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 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