Connect Pi-hole container to LAN

I managed to get pi-hole running on a Linux container via Docker for Windows (WSL 2).
It works fine and really good.

The only thing I can't get wrap my head around, is how to connect the pi-hole to the LAN, or specifically have it so that the clients can connect to the pi-hole directly.

The IP address of the pi-hole sits "inside" the host, and I guess transactions are NAT'ed and port forwarded to the actual container.
The issue I have with this is that, the number of clients seen and logged by the pi-hole is just one, which is the IP address of the host relative to the docker's internal network. something like
So imagine you have multiple client devices on the network, and you go to pi-hole to check logs for a specific client, like when you're troubleshooting, or checking trends with a specific client.. you cant do that because every devices' activity would be logged behind that one IP.


1 Like

TLDR; It's WSL2 and networking with Docker, I don't think you'll be able to do what you want.


Docker for Windows is crippled when compared to configuration options for a plain Linux installation.

You'd normally forfeit network isolation and switch to a different network mode (host), but that isn't available in Docker for Windows (and that's not the only limitation).

You'd probably be better off getting yourself an RPi Zero (quite capable as a Pi-hole machine).

1 Like

Indeed, WSL is a nice tool but has some naughty limitations.

I'd also suggest getting a Raspberry Pi, or investing on a small PC to be used as headless server. Almost 3 years ago I bought a Mini PC to install Ubuntu and toy with it, and it went so well that it became my Server running some useful services. Now I'm buying a proper PC to use as Server and NAS.

It's totally worth it. Once u start learning real linux and getting ur things working, u'll never stop and only install more services. Maybe a Raspberry won't be able to run it all.

Still, at least drop WSL docker and get a proper VM, be it virtual box, vmware (now supporting DirectX 10 and awesome to run some games that are old enough to not require huge resources and also not old enough to use DirectDraw or older D3D), etc.

vmware allows to set VM network as bridged, this way it sees LAN and any LAN device can see it directly.

1 Like

Ahh I was starting to think it was a limitation. Im very new to docker and containers and thought Windows WSL is a good place to start, since it was very easy to get running.

I have a bit of knowledge with Vmware and Hyper-V from working as a system admin.

Do you think I can get what im after if I go with a Hyper-V VM running Ubuntu?

1 Like

Thanks for this. That explains a lot.

I have a Hyper V host. If i create a VM running ubuntu for example, I know i can get that connected to the LAN directly.

So if i get the pihole running in a container in a linux vm, I can get what im after?

Im very new to docker and containers in general. Which explains why I went for Docker for windows. :sweat_smile:

1 Like

You really can't.

Then get a Raspberry Pi or similar SBC and run Pi-hole on that until you gain the knowledge of what you can and can not do with Docker and Hyper-V.

1 Like

IMHO, WSL came too late. It'd be very helping a couple decades ago when we didn't even have money for a 2nd HD, Lix install used to destroy Windows partitions, and PCs were unable to run VMs.

Now, we can just have a 2nd PC running the secondary OS, or run it on VM. I have my Server with NAS, a NUC with Win10 which I plan to deactivate soon, a VM with Ubuntu and some VMs with Win10 for multiple usages. WSL (+ Windows Terminal) is useful only as a prettier console than Putty to ssh my other stuff.

I advice against WSL and any BusyBox distro as they have sad limitation. For starting, Ubuntu on a VM is by far the easiest and best feature-wise path to take.

Anything I wanted to install I was able to o Ubuntu, so for myself other distros like Arch, Slackware, etc aren'te needed. In a couple years I plan to build a PC and use it as my router, with OPNsense and FreeBSD.

I had used Docker on my QNAP and didn't like it. Looks like it doesn't let us change any setting after a container was created. It's awesome for cloud solutions that are RESTLESS, but very bad for any other use. It seems to be just a quick way to install services/softwares instances around.

Just install pihole on Ubuntu and start learning about them. That includes dnsmasq, as grabbing blacklists to add.

But remember that the VM is limited to the host availability. It's not good to have DNS server running on a VM inside your desktop. You may need to reboot it, on the right moment a device is updating its lease, and that cause it to think the DNS server is down and stop using it until the next lease.

Use the VM to learn, set a couple devices only to use it. Then move to a Raspberry Pi or to a small PC. As I said, after some months using BusyBox on my NAS, I bought a Mini PC to see what I was able to do on a full Lix distro and it turned into my server with Pihole, Tor, some proxies, multiple Transmission instances, CrashPlan, some neat monitors, etc etc etc. We just go learning new stuff and wanna get it working, moving to it stuff we used to run on Windows.

In the long past, I used to run TreeWalk on my PC. It's an old DNS server for Windows based on BIND source code, from a time when BIND didn't run on Windows.

Pihole was created precisely to be ran on a small Raspberry Pi and is still able to, but there are a lot of other stuff we might run at home that makes one too weak to handle.

1 Like

Thanks for the helpful advices!

I decided to nuke the Windows docker pihole container and instead spun up a VM running Ubuntu server 20.04 on my existing Hyper-V host, here at home. I'm sure I'll find other useful services to run on docker but for pihole, at least for my use case, it running on an Ubuntu VM natively solves my issues and it now works perfectly.

Thanks again!