2024年11月24日星期日 上午1:25:43

Network How To Use mDNS Within Docker Container

8 个月 前
#29776 引用
How To Use mDNS Within Docker Container
https://devmemo.io/blog/use_mdns_within_docker_container/


How to configure the Home Assistant Docker container for mDNS?
https://community.home-assistant.io/t/how-to-configure-the-home-assistant-docker-container-for-mdns/379172

树莓派中配置mDNS服务
https://blog.csdn.net/weixin_46084533/article/details/135488050


mDNS 协议来定位局域网主机
https://blog.beanbang.cn/2019/08/07/locate-hosts-using-mdns/
0
8 个月 前
#29786 引用
Does Docker work with mDNS
https://forums.docker.com/t/does-docker-work-with-mdns/137508

The docker engine will use the dns resolver configured in /etc/resolv.conf.
A container started in the docker engine will use docker’s build-in dns resolver, which uses the resolvers from the hosts /etc/resolv.conf as upstream.

Looks like mDNS is running on your host and binds to an ip in the range 127.0.0.0/8. Of course a container will not be able to access it there.

It would work for the host and the containers, if mDNS is configured to bind the port to the ip (by default: 172.17.0.1) of docker0 interface, it would be reachable from the host and the containers, without exposing the service to your lan. If your lan ip is static, you could use your lan ip instead and expose the resolver to your whole lan.
0
8 个月 前
#29787 引用
  # Required for mDNS to Docker work correctly
    network_mode: host


version: "3.8"
services:
  # python-matter-server
  matter-server:
    image: ghcr.io/home-assistant-libs/python-matter-server:stable
    container_name: matter-server
    restart: unless-stopped
    # Required for mDNS to work correctly
    network_mode: host
    security_opt:
      # Needed for Bluetooth via dbus
      - apparmor:unconfined
    volumes:
      # Create an .env file that sets the USERDIR environment variable.
      - ${USERDIR:-$HOME}/docker/matter-server/data:/data/
      - /run/dbus:/run/dbus:ro





https://github.com/home-assistant-libs/python-matter-server/blob/main/compose.yml
0
8 个月 前
#29807 引用
mDNS/Zeroconf is  supported in HA Core via Docker

The current documentation() states that one should use host network to have mDNS/Zeroconf discovery working in Docker

With HA Core container is on the host network, the container will get the mDNS entries and Zeroconf integration will get notified of them and even start the flow to notify the admin that a new device that can be integrated has been found.

However, the notification never actually appears as the container is unable to resolve the ".local" mDNS names, so the flow terminates!

The reason for this is because the HA images are based in Alpine and unfortunately Alpine doesn't have the necessary support for mDNS names resolution (normally via libnss-mdns).

This is also the reason why HA Supervised installations have an mDNS reflector and an internal DNS resolver (that basically allows for regular DNS queries to also resolve mDNS entries).

https://github.com/home-assistant/home-assistant.io/issues/14153
0