Pi 1 -> docker migration

Hello! After some best-practice top tips, please. Learning docker as we go here, so please be gentle :slight_smile:

Current: ancient raspberry pi 1 running pihole; DNS and DHCP. Working fine.
Intended: 8gb pi4 docker container; DNS and DHCP (alongside other unrelated containers)

It hasn't worked perfectly immediately and I've worked through a few errors, but I'm wondering if there are some obvious container best practices I'm missing.

Current issue showing on pihole diagnosis is no address range available for DHCP request via eth0. DHCP lease range and gateway are correct. Clients are getting an IP on the correct subnet, but have incorrect gateway and DNS addresses. There aren't any leases shown on the web dashboard, so I think clients are getting addresses from...elsewhere?! Router DHCP is disabled, FYI.

Thanks in advance,
Matt

1)

Which network mode are you using? bridge, host, macvlan?
Please post the compose file or docker run command used to start the container.

2)

Also, a debug log might help you understand your LAN and DHCP setup.

Please upload a debug log and post just the token URL that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

pihole -d

or do it through the Web interface:

Tools > Generate Debug Log

Then it's likely that you've started your Pi-hole container with Docker's default brigde network.
This would isolate your container in its own virtual network segment, effectively cutting it off from receiving your clients' DHCP broadcasts (because those would be on another link or network segment).

You'd have to switch to a suitable Docker network mode driver.
Our Docker DHCP and Network Modes - Pi-hole documentation should help you get started.

Thank you both for the help.

I have looked in to the network modes and now have the current run command:

docker run -d --name=pihole -e TZ=Europe/London -e WEBPASSWORD="xyz" -e FTLCONF_LOCAL_IPV4=192.168.0.2 -v /mnt/NAS/pihole/etc-pihole:/etc/pihole -v /mnt/NAS/pihole/etc-dnsmasq.d:/etc/dnsmasq.d --cap-add=NET_ADMIN --net=host --restart=unless-stopped pihole/pihole

which has no errors, but I am yet to test clients using DHCP.

I have noticed that running net=host disregards any ports specified (so I have removed those from the run command). Am I right that if I run other containers that, say, need a web interface, I shall have to specify -p 8081:80 for example so they do not conflict?

Given clients on my network will already have their IPs leased, I am planning on shutting down the old pi1 and using the same IP address on the new pi4 host, so that network clients can use the same name server - any obvious concerns there?

Thanks,
Matt

You are correct. When you use host network mode, the container will use the same ports the host uses and will ignore the -p argument.

To avoid conflicts you need to change the container port using Pi-hole advanced environment variable WEB_PORT. You need to add -e WEB_PORT=8081 to your command.

1 Like

Thank you all. Network mode looks to be what I was looking for.

New pi is in place, running pihole container. IPs are being leased and I am reaching the internet to type this, so we're looking good. Old pi1 will be kept as a rollback plan for a while :slight_smile: