I had the same problem as Pihole v6 DHCP advertises docker IP instead of server IP address to clients
Rather than a custom dnsmasq config, I found a setting in the PiHole v6 web GUI that solved the problem for me. It's under the "All Settings" section. This section is hidden unless you go to Settings > System and toggle the "Basic/Expert" switch in the top right (bright green/red). Once you've switched to "Expert", a new section appears under the Settings in the sidebar on the left.
All Settings
dns.reply.host.force4: check
dns.reply.host.IPv4: The IPv4 address of your Docker host, the actual machine that's running your Docker containers!
Since this can be difficult to follow from a text dexcriotion to a gui, you can also see these settings in /etc/pihole/pihole.toml
force4 = true ### CHANGED, default = false
IPv4 = "192.168.1.128" ### CHANGED, default = ""
(of course, replace that 192.168.1.128 with the IP address of your docker host, not mine !
)
The discussion on this site helped me after weeks of frustration. I hope this helps a bjt too.
The preferred way of doing this would be passing your host's network IP address as container environment variables, e.g. for docker compose (assuming that IP would be 192.168.1.128
):
services:
pihole: (…)
ports: (…)
environment:
(…)
FTLCONF_dns_reply_host_IPv4: '192.168.1.128'
FTLCONF_dns_reply_host_force4: true
Thank you.
Keeping all custom configuration info in a single place is always a better idea than relying on configuration files (in this case, etc-pihole/pihole.toml
) that are likely to be overwritten upon the next invocation of docker compose ...
In my case, I have added a copy of pihole.toml
to a local git
repository, and I'm trying to track changes there until I get enough familiarity with the Docker workflow.
I just tried applying all of my local customizations in the compose.yaml
file, but I ran into problems with array-valued items.
For my upstream DNS, for instance, I tried
services:
pihole: (...)
ports: (...)
environment:
(...)
FTLCONF_dns_upstreams: ['8.8.8.8','8.8.4.4']
but that is either invalid YAML or the wrong Docker Compose notation; I got an error and it wouldn't build.
Since I had multiple sources of configuration data anyway, I keep it in a directory and wrangle it with a Makefile
and git
. It is indeed tedious to track the changes.
Suggestions on how to fold it all into a single Docker Compose file are greatly appreciated!
Use this:
FTLCONF_dns_upstreams: '8.8.8.8;8.8.4.4'