Why Is My Pi-hole Container Using the Wrong IP Address in Docker?

0
22
Asked By TechWhiz123 On

I recently set up Pi-hole on my Windows 11 machine using Docker Desktop and the command line. I intended to assign it a static IP of .185, but it defaulted to an IP of .200, which is the same as my host machine. Initially, I was excited to see it listed in Docker Desktop, but then I noticed that my specified IP and password didn't carry over. Can anyone explain why this happened and how I can change the IP back to .185? Additionally, I attempted to create a custom network but ran into an error stating that the name was already in use by another container. I'm using the following command as a reference:

docker run -d --name pihole -e ServerIP=YOUR_STATIC_IP -e WEBPASSWORD=YOUR_PASSWORD -e TZ=YOUR_TIMEZONE -e DNS1=127.0.0.1 -e DNS2=1.1.1.1 -p 80:80 -p 53:53/tcp -p 53:53/udp --restart=unless-stopped pihole/pihole:latest

I also tried this syntax for setting up the custom network:

docker run -d --name my_container --net custom_network --ip 192.168.1.10 my_image
docker run -d --name Pi-hole_2 --net custom_network --ip 192.168.1.185 my_image

3 Answers

Answered By DockerGenius42 On

Just so you know, Docker tends to use your host machine's IP for exposing services, so when you set the IP for Pi-hole, that's just for external identification, not to assign it a new internal Docker IP. Also, creating MACVLANs is a bit different, but on Docker Desktop with WSL2, the necessary functionalities might be limited.

Answered By LinuxLover99 On

Honestly, I wouldn't recommend running Pi-hole on Docker Desktop for Windows. It's better to use a dedicated device, like a Raspberry Pi, for it if you can. It'll save you a lot of headache.

PiHoleFan88 -

I understand that, but I really don't want to shell out a bunch of cash on a Raspberry Pi right now.

Answered By NetworkingNinja15 On

One thing you might want to check is that the IP you specify for Pi-hole isn’t actually creating a new one. In Docker, to successfully use a MACVLAN, you first set up the network and then link your container to that network. But remember, Docker Desktop creates a virtual machine that may have its own network restrictions. If you're having trouble connecting to the custom network, make sure the container name isn't clashing with existing ones. You can't have two containers with the same name, after all.

DockerEnthusiast54 -

I thought I set up the network correctly, but connecting the container gives an error like it's already in use. I read something about using Nginx as a bridge if installed on the same host. Is it possible to just use Pi-hole_2 and the static IP I wanted to set?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.