You were right about NetworkManager spawning a new dnsmasq instance when setting connection mode to shared
. This runs on the same IP that you need pi-hole’s dnsmasq instance to run, so the port will not be available indeed. Manual option is the correct one for this case.
My suggestions would be:
-
For connection sharing there are two possibilities NAT and bridged. I think you will be better off for your use case with NAT. This is also what NetworkManager does in its shared mode.
-
Install pi-hole in a recent Debian container. Usually I go with either Stretch or even the unstable Buster if I have issues on Stretch.
-
I looked at pi-hole’s installer. It checks for
nmcli
availability.nmcli
is the command line interface of NetworkManager. It communicates with NetworkManager through D-Bus. You may install NetworkManager inside the container, so that the installer invokes nmcli. However do not forget to mask the NetworkManager’s service:RUN apt-get update && apt-get install -y network-manager && systemctl mask NetworkManager.service
. You will need also to export the correctDBUS_SYSTEM_BUS_ADDRESS
address, so thatnmcli
communicates with the NM service running on the host OS. More information on this here: https://docs.resin.io/reference/OS/network/2.x/#changing-the-network-at-runtime -
If you are running a multicontainer setup you need to set docker compose
network_mode
tohost
. -
Investigate what the pi-hole installer does, as it may well set networking for your use case. I have not done that, so I am not sure whether it will do that or not.
-
Here is another topic related to Internet connection sharing that you may find useful which includes a sample repo from a forum user: Route Wireless to Wired with resinOS 2.x and RPi 3
-
You may find useful the create_ap script, which is for creating Access Points with Internet sharing (it uses hostapd instead of the lightweight built-in access point NetworkManager creates, but it can still be useful for creating the AP, or as a reference at least): https://github.com/oblique/create_ap
Hope that is helpful