简体   繁体   中英

Zeroconf discovery from docker-compose container to LAN host

For an IoT system there is the requirement that base stations automatically discover nearby devices, and then connect to them. The software on the base stations is deployed using docker-compose.

Services advertise using mDNS (zeroconf), and identify themselves as being of the type mytype . Clients use aiozeroconf to discover services matching _mytype._tcp.local. .

The problem is that clients inside a docker-compose network don't discover services in the LAN network - even if they are otherwise reachable.

Currently, I have the following setup:

LAN (Wifi)
  - IoT device
    - ServiceA
  - Host / base station
    - ClientA
    - Docker-compose network
      - ServiceB
      - ClientB
  • ClientA finds both ServiceA and ServiceB
  • ClientB finds ServiceB
  • avahi-discover on Host finds both ServiceA and ServiceB
  • ClientB can connect to ServiceA using the LAN IP (192.168.xx)

Is this scenario considered out-of-spec for mDNS (ServiceA no longer considered in .local), or can this be solved?

您可以使用mdns-repeater将 mDNS 数据包从主机网络转发到 Docker 网络,并使容器能够发现 LAN 中的设备。

The avahi-daemon conf supports the reflector/enable-reflector setting.

When enabled, the daemon will forward all mDNS packets to all other network interfaces, including Docker bridge networks. Assuming an uncomplicated network architecture, docker-compose services will now be able to discover devices on the local network.

There are scenarios where reflection is undesired behavior. If the host is connected to multiple local networks, other hosts may get mDNS packets for unreachable services.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM