Run pihole in a docker container
Clone this repo and run
./pihole as explained below:
Works on Linux and on MacOS.
In its simplest form, just run:
The script attempts to glean the existing DNS configuration and to configure the container to use those servers as its upstream resolvers.
If that won't work, just pass the explicit servers as arguments on the command line.
For examplem to set up pihole to hit Cloudflare's servers, do this:
PiHole configuration (additional block lists, etc.)
./lists script here sets up the pihole configuration as
explained in this blog post:
pihole shell script waits for the container to be operational and then
it runs the configuration script. Configuration data persists in the
By default, this script is set up to use the Quad9 DNS servers.
Once the pihole container is up, set up your laptop's DNS to use 127.0.0.1 as its DNS.
Set up MacOS DNS settings via commandline
To set up the DNS on MacOS, you can do:
networksetup -setdnsservers Wi-Fi 127.0.0.1
To reset it (when you are no longer using it):
networksetup -setdnsservers Wi-Fi Empty
If you are using a different network adapter, you may have to replace
Wi-Fi above with whatever the appropriate service name is, gleaned by
Stopping pihole, upgrading, etc.
To stop the container, you can use
docker stop pihole
To restart the container,
docker start pihole
To destroy it entirely,
docker rm -f pihole
Upgrade by doing a
docker rm -f pihole docker pull pihole/pihole ./pihole