Run pihole using pihole in docker
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Run pihole in a docker container

See this:

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.)

The ./lists script here sets up the pihole configuration as explained in this blog post:

The pihole shell script waits for the container to be operational and then it runs the configuration script. Configuration data persists in the ./config/ directory.

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 as its DNS.

Set up MacOS DNS settings via commandline


To set up the DNS on MacOS, you can do:

networksetup -setdnsservers Wi-Fi

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 the Wi-Fi above with whatever the appropriate service name is, gleaned by running networksetup -listallnetworkservices

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 pull:

docker rm -f pihole
docker pull pihole/pihole