Table of Contents

Pi-Hole - Setup Pi-Hole running in Docker and Portainer

Install Docker

curl -ssl https://get.docker.com | sh

Install Portainer

This is always one of the first container to pull and run, because like me you are lazy and cannot remember more than 2 lines of code.

Create a volume to host Portainer data

docker volume create portainer_data

returns

portainer_data

Install the Portainer Docker Image

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data --restart always portainer/portainer

NOTE: This will run the container to pull, install and ensure it is always running.


Check that Portainer is running

docker ps

Configure Portainer

Navigate to http://yourdeviceip:9000.

Portainer will prompt you to set up a new password for your admin user.


Connect Portainer to Docker

Click Local and Connect.

NOTE: If using a remote Docker then select the appropriate Remote option.


Select the local docker

Select your local docker:


Install Pi-hole as a new container

Add Container

Navigate to Containers.

Click Add Container.


Create Container


Map some volumes

In Advanced container settings:

NOTE: Bind mounts are used rather than standard volumes since that allows the location to the folder to be mapped instead of creating a volume in the Docker volumes folder.

The /home/peter/pihole/ directory will be automatically created.


Set up the network

This also sets the DNS the image should use.

In Advanced container settings:

NOTE: As of version 4.1.1 of Pi-Hole, the DNS server for the Docker container itself, localhost (127.0.0.1), must be set as the primary DNS server.

The secondary DNS server can be any other DNS server you prefer.


Set the Environment

Ensures that Pi-hole starts automatically.

In Advanced container settings:

NOTE: Pi-hole will default to Google DNS Servers of 8.8.8.8 and 8.8.4.4 if the DNS1 or DNS2 environment variables are not set.

If only 1 upstream DNS server is wanted, put no as the value for the DNS2 variable, otherwise it will default to Google secondary DNS server 8.8.4.4.

It is recommended to have two upstream DNS servers in case one goes down.


Set the Restart Policy

Ensures that Pi-hole starts automatically.

In Advanced container settings:


Deploy the Container

Click Deploy the Container.