How YOU can block all ads with Docker

Docker Pi-Hole

Pi-Hole for the Raspberry Pi is awesome. But I don’t like the idea of bringing my Raspberry Pi to every coffee shop I go to. So, how can we get around this? With the power of Docker. Docker is really awesome because you can run it on a server, or your own laptop. Docker containers are like Virtual Machines. Although, containers are way faster and require less computing power. What’s cool about containers is that everything inside them is isolated from the host computer.

You can setup a docker container running Pi-Hole easily.

This tutorial is made for Mac OSX. Although, everything should be somewhat the same on Windows, and Linux.

So, let’s get started.

Installing Docker

We can’t do this without docker, so here’s a link to install docker.

Creating The Container

Open up a terminal. (This command is a little large).

docker run -d \
    --name pihole \
    -p 53:53/tcp -p 53:53/udp \
    -p 80:80 \
    -p 443:443 \
    -e TZ="America/New_York" \
    -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

That command will pull the latest Pi-Hole image from docker and run the container.

Configure Pi-Hole

Once you’ve run the above command, wait a few minutes for Pi-Hole to finish setting up. Then visit 127.0.0.1 in your browser, or your local ip address. You will see a page appear, it will ask you if you wanted to see the admin panel instead. Click that link. Or you could just visit 127.0.0.1/admin.

Then click the Login on the sidebar. You’ll need a password in order to continue.

Open up your terminal again, and use this command to retrieve the randomly generated password.

docker logs pihole | grep random

Make sure that pihole is the name of the Pi-Hole docker container.

The output should be something like this:

Assigning random password: 3KYqVLBD

That’s your admin password.

If you did everything correctly, you’ll be redirected into the Pi-Hole dashboard.

Final Setup – Configure DNS

On Mac OSX, go to System Preferences > Network > Wi-Fi > Advanced

Then click DNS on the top bar. Click the plus button at the bottom, and add 127.0.0.1.

Click OK and then Apply.

If you’re using Windows 10, try this link.

You’re Finished!

If you’ve done everything correctly, your container will start blocking ads right away!

Important Notes

You will probably run into some trouble if you’ve got a program running on port 80 (Apache).

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *