I tried putting pi-hole on the box by installing WSL2 and running a Debian instance, then installing it. This resulted in a lot of "WSL2 limitations" coming to light, specifically related to the windows network stack. After crashing the struggle bus multiple times, I decided to go into unknown Docker territory as an excuse to fool with Docker on windows.
Here's the recipe for success:
Prerequisites
- Windows with WSL2 and Docker Desktop installed
- PowerShell with administrator access
Step 1: Create Docker Compose Configuration
Create a dedicated directory for Pi-hole and the Docker Compose configuration:
mkdir C:\pihole
cd C:\pihole
Create a file named docker-compose.yml
in the C:\pihole
directory:
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "80:80/tcp"
environment:
TZ: 'America/New_York'
WEBPASSWORD: 'admin123'
PIHOLE_DNS_: '8.8.8.8;8.8.4.4'
DNSMASQ_LISTENING: 'all'
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
cap_add:
- NET_ADMIN
restart: unless-stopped
Step 2: Create Data Directories
Open PowerShell in the same directory and run:
mkdir -p etc-pihole, etc-dnsmasq.d
Step 3: Start Pi-hole
docker-compose up -d
Step 4: Set Admin Password
docker exec pihole pihole setpassword 'admin123'
Step 5: Configure Windows Firewall
Run PowerShell as Administrator and execute:
New-NetFirewallRule -DisplayName "Pi-hole DNS TCP" -Direction Inbound -Protocol TCP -LocalPort 53 -Action Allow
New-NetFirewallRule -DisplayName "Pi-hole DNS UDP" -Direction Inbound -Protocol UDP -LocalPort 53 -Action Allow
Final Configuration
Once setup is complete, you'll have:
- Web Interface: http://[YOUR-WINDOWS-IP]/admin/ (e.g., http://192.168.1.3/admin/)
- Admin Password:
admin123
- DNS Server: Your Windows IP address on port 53
- Data Persistence: Stored in
./etc-pihole
and./etc-dnsmasq.d
directories
Management Commands
Here are some useful commands for managing your Pi-hole installation:
- Stop Pi-hole:
docker-compose down
- Start Pi-hole:
docker-compose up -d
- View logs:
docker logs pihole
- Reset password:
docker exec pihole pihole setpassword 'newpassword'
No comments:
Post a Comment