On my host Raspberry Pi 4, I have no issues resolving the DNS name.
However, within the Docker container on that host, I cannot resolve it.
(I have no issues pinging public internet domains/DNS names from the host and the container.)
Is this a configuration that can be somehow added to the Home Assistant Docker image? Or only something that can be configured myself after pulling/running the Home Assistant Docker image?
# Successful ping with DNS name from host machine
pi@raspberrypi ~> ping eagle-xxxxxx.local
PING eagle-xxxxxx.local (192.168.1.6) 56(84) bytes of data.
64 bytes from 192.168.1.6 (192.168.1.6): icmp_seq=1 ttl=64 time=0.510 ms
64 bytes from 192.168.1.6 (192.168.1.6): icmp_seq=2 ttl=64 time=0.314 ms
^C
--- eagle-xxxxxx.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.314/0.412/0.510/0.098 ms
# Unsuccessful ping with DNS name from Docker container on host machine
pi@raspberrypi ~> docker exec -it homeassistant /bin/bash
bash-5.1# ping eagle-xxxxxx.local
ping: bad address 'eagle-xxxxxx.local'
bash-5.1# ping 192.168.1.6
PING 192.168.1.6 (192.168.1.6): 56 data bytes
64 bytes from 192.168.1.6: seq=0 ttl=64 time=0.720 ms
64 bytes from 192.168.1.6: seq=1 ttl=64 time=0.829 ms
^C
--- 192.168.1.6 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.720/0.774/0.829 ms
# Confirmed that Docker copied in the host's nameserver correctly
pi@raspberrypi ~> cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
...
pi@raspberrypi ~> docker exec -it homeassistant /bin/bash
bash-5.1# cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
...
Yes, it is a container installation, I thought that was the only Docker-centric one on Raspberry Pi.
Yes, the Docker command is copied from that page, docker run ... --network=host ..., which I believe allows the container to copy in the host’s /etc/resolv.conf file.
That doesn’t do anything in relation mDns; mDns doesn’t use any DNS server, it’s a multicast based protocol
That bind mount is specific to @WeterPeter. Nobody knows what is in the “/volume2/docker2/homeassistant/config/resolv.conf” file he mounts inside the HA container
That breaks docker’s own DNS resolution mechanism. Your mileage might vary, here…
Bottom-line: Happy it works for him, but don’t try this at home
For anyone that might stumble on this.
Should you decide not to use network_mode: host and instead make your own network for the container. The mDNS can be made working should used avahi reflectors in the configuration.
Just enable them in /etc/avahi/avahi-daemon.conf and restart the avahi daemon systemctl restart avahi-daemon.
For the sake of completeness, be aware that enabling the reflector in the avahi configuration makes that mDNS will be reflected on ALL your interfaces.
While it is not a problem as such for most people, keep in mind that if you have more than one interface (e.g. a separate IoT subnet or VLAN), you can only have one reflector on these networks, otherwise they will start to re-advertise each other announcements!