Skip to content

Instantly share code, notes, and snippets.

@PiotrKrzyzek
Created December 17, 2018 03:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save PiotrKrzyzek/8a5cf195a34e9f37fdbef811e83fae2f to your computer and use it in GitHub Desktop.
Save PiotrKrzyzek/8a5cf195a34e9f37fdbef811e83fae2f to your computer and use it in GitHub Desktop.
Config and run pihole in Docker on MacOS
#!/bin/bash
# I've set this up to use my static IP, instead of dynamically getting one.
# Why? Because if my IP keeps changing, then how is the router supposed to constantly find it?!
# I set a static IP for this computer, and that is that.
IP="YOUR local static IP here"
# Default of directory you run this from, update to where ever.
DOCKER_CONFIGS="~/.pihole"
docker run -d \
-p 53:53/tcp -p 53:53/udp \
-p 67:67/udp \
-p 80:80 \
-p 443:443 \
-e ServerIP="${IP}" \
--restart=unless-stopped \
--cap-add=NET_ADMIN \
--dns=127.0.0.1 --dns=1.1.1.1 \
-v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \
-v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \
-e WEBPASSWORD="YOUR PASSWORD HERE" \
pihole/pihole:latest
# Q&A
## Why is the password set here?
# I was tired of having to always find the password. So, since I only have access to the system
# I just set it to something I know
## Where did you put this file?
# I placed it into the ".pihole" folder in my users home directory
@gstbreese
Copy link

This was really helpful, thanks! I used this on a Mac running Docker v2.3.0.2, Catalina v10.15.5.
When I ran the script it choked on ~, changing to an explicit path worked.

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