Skip to content

Instantly share code, notes, and snippets.

@jostyee
Created March 27, 2019 09:37
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 jostyee/1cad5d8d13b1788ac18d422f91c9d5b1 to your computer and use it in GitHub Desktop.
Save jostyee/1cad5d8d13b1788ac18d422f91c9d5b1 to your computer and use it in GitHub Desktop.
Run pi-hole in macOS
#!/bin/bash
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp \
-p 80:80 \
-p 443:443 \
-e ServerIP="$(ipconfig getifaddr en0)" \
-e TZ="Asia/Singapore" \
-e WEBPASSWORD="s0me_Random-string$" \
-e DNS1="1.1.1.1" \
-e DNS2="8.8.8.8" \
-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 start, consult check your container logs for more info (\`docker logs pihole\`)"
exit 1
fi
done;
#!/bin/bash
networksetup -setdnsservers Wi-Fi 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment