My Pi-hole installation is done the way of virtualization via Docker. There is no other easy way to install it on Arch Linux since the developers of pi-hole only support Debian based Linux distrobutions. Luckily they packaged Pi-hole in Docker as well to make it deployable on any operating system.
Just like my tutorial for the Arch Linux Installation on a Raspberry Pi 4, all work will be done via Terminal.
Also this tutorial is going to assume the host operating system is Arch Linux, building off the previously linked tutorial.
First we need to make sure the docker and docker-compose packages are installed.
$ sudo pacman -S docker docker-compose
Docker Compose is mainly a tool that is used for complex production environments, which orchestrates the deployments and updates of multiple containers from a single file. However, I like to use it in my home network for single containers because the docker-compose.yml file makes it easy to reference container settings in future.
I recommend creating a directory just for docker volumes. This is where the containers will store persistent information to be used between old and newly updated containers.
The directory I have all my containers in is
/home/my-user-name/docker/container-name. So in this case we will work in the ~/docker/pihole directory.
~/ is shorthand for the current user's home directory.
Enter the below commands to create the ~/docker/pihole directory, and to create the pihole container's configuration file.
$ cd ~
$ mkdir docker && mkdir docker/pihole
$ touch docker/pihole/docker-compose.yml
Next we will add the config to the docker-compose.yml file with a command line text editor. I prefer Vim, however nano is more beginner friendly.
$ vim docker/pihole/docker-compose.yml
To copy and paste in a terminal, the keyboard shorcuts are Ctrl+Shift+c for copy, and Ctrl+Shift+v to paste.
Below is my docker-compose.yml file.
Be sure to replace [username] with the current user you are logged in as. You can find this out with the command
who.
version: "3"
# More info at https://github.com/pi-hole/docker-pi-hole/
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
hostname: pihole
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "80:80/tcp"
environment:
ServerIP: 192.168.5.53 #internal IP
ServerIPv6: [redacted]
TZ: 'America/New_York'
WEB_PORT: '80'
WEBPASSWORD: [enter your own password here]
PIHOLE_DOMAIN: 'petesplace.lan' # local network's domain
# Volumes store your data between container upgrades
volumes:
- '/home/[username]/docker/pihole/etc-pihole/:/etc/pihole/'
- '/home/[username]/docker/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/'
# Recommended but not required (DHCP needs NET_ADMIN)
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
cap_add:
- NET_ADMIN
restart: unless-stopped #restarts after reboot
Now it's as simple as spinning up the container with docker-compose.
$ cd docker/pihole/
$ sudo docker-compose up -d
Docker will now download the image, and create all the virtual networks and virtual storage devices necessary for the container to run.
You can access the user interface by navigating to your servers private IP address that was set in your docker-compose.yml file, via web browser.
You can either set your router's DNS address as the server's IP, or you can individually change the DNS server on each device connected to your network.
I recommend changing your router's DNS setting because thanks to a recent update, you can now manage blocklists for each individual device through the Pi-hole web interface.