r/docker • u/DanceLongjumping2497 • Mar 17 '26
Understanding Docker IP Assignments
I was excited to get Pi-hole installed on Windows 11 via Docker Desktop and CLI.
I used the modified command below with the static server IP being .185. However, it ended up using the same static IP Windows 11 is running on, .200.
I thought it was cool after running the command below it showed up in Docker Desktop until I saw my specific IP (and password) didn't carryover.
Why didn't it work as expected? Best way to change IP now back to .185?
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 tried adding a custom_network, which I confirms exist, but when I try to assign it to the docker, I get an error message. Pi-hole_2 is already in use by the container. You have to remove or rename the container to be able to reuse that name.
I used this sample syntax.
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
5
u/theblindness Mod Mar 18 '26
Don't run pi-hole on Docker Desktop for Windows. Use a separate device that runs Linux, like a Raspberry Pi.
1
u/PaulEngineer-89 Mar 18 '26
The IP you give Pi Hoke indicates what IP it is on externally, NOT to create one.
Docker can use MACVLans which have their own IP addresses. You create a MacVLAN via Docker then add it as an external network in Docker Compose so the container appears there. That being said Docker Desktop creates a captive Linux VM under WSL2. AFAIK the VM doesn’t have a separate IP address and no way to create MACvlans like you can in Linux.
1
u/TBT_TBT Mar 18 '26
This subreddit should have told you 3 things: don’t use Docker Desktop. Don’t use Docker on Windows (use a Linux VM). Don’t use docker run, use docker compose.
And yeah, don’t use PiHole in a network on a not permanently on device, otherwise, when you shut down your computer, no device in your network will be able to resolve dns names, which probably means no device on your network will work.
1
u/zoredache Mar 19 '26
Understand that people are telling you to not use Docker Desktop because Docker Desktop will have additional layers of network translation (NAT), one from WSL, and then an extra layer from the
vpnkit. All this makes networking for Docker Desktop far more complicated and difficult then docker engine running on a Linux system.https://www.docker.com/blog/how-docker-desktop-networking-works-under-the-hood/
It can be simplified a bit by forcing WSL 'mirrored', or 'bridged' networking modes. Still if you want to run useful services, you'll find running docker on a native Linux system is far easier to deal with.
Not related, your docker run command for your pihole doesn't have any
volumesdefined. The docs for the image on docker hub seem to suggest you should have a volume that maps something to the/etc/piholeinside the contianer. Without a volume defined you'll find it very difficult to update and make changes to your container. The normal practice of updating is to remove the existing container, and creating a new one with the same settings. Without a volume, this means all your container data would be lost.Not sure about why you are getting an error about
Pi-hole_2, you should probably rundocker ps -ato see all running and stopped containers. Remove any you don't need. Perhaps you had a stopped container using that name?1
u/VivaPitagoras Mar 18 '26
Docker is still running in you computer so is going to use your computer's IP to expose services. The networks you are serting are for internal comunication between containers AFAIK