我正在运行一个基于ubuntu:14.04的容器,我需要能够在其中使用avahi-browse
。然而:
(.env)root@8faa2c44e53e:/opt/cluster-manager# avahi-browse -a
Failed to create client object: Daemon not running
(.env)root@8faa2c44e53e:/opt/cluster-manager# service avahi-daemon status
Avahi mDNS/DNS-SD Daemon is running
我遇到的实际问题是
pybonjour
错误; pybonjour.BonjourError: (-65537, 'unknown')
,但我已阅读到与avahi-daemon的问题有关的链接。所以;如何从容器连接到avahi-daemon?
附言我必须在avahi-daemon.conf填充中关闭dbus才能启动它,否则avahi-daemon不会启动,并出现dbus错误,如下所示:
(.env)root@8faa2c44e53e:/opt/cluster-manager# avahi-daemonFound user 'avahi' (UID 103) and group 'avahi' (GID 107).Successfully dropped root privileges.avahi-daemon 0.6.31 starting up.dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directoryWARNING: Failed to contact D-Bus daemon.avahi-daemon 0.6.31 exiting.
最佳答案
据我测试,您可以通过Unix套接字使用主机的avahi-daemon进行mDNS解析,并使用/ var / run / dbus进行avali浏览。
例如。:
docker run -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -ti debian:10-slim bash
要测试容器内部:apt-get update && apt-get install avahi-utils iputils-ping -y
ping whatever.local
avahi-browse -a