英文:
Why does running avahi-browse within a docker container returns (NULL) network interfaces?
问题
I'm attempting mDNS discovery from within a Docker container and running it using
sudo docker run --privileged -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -d -p 5001:5001 my_application
as shown in this post
When running avahi-browse within the container, I get this output:
root@38ca93e44ce1:/etc/avahi# avahi-browse -a
+ (null) IPv4 amzn.dmgr:2A9009CCFEAFDF82846897DD0D687295:xnVDMM+4u1:767308 Amazon Fire TV local
+ (null) IPv6 Canon MG7700 series _uscan._tcp local
+ (null) IPv4 Canon MG7700 series _uscan._tcp local
+ (null) IPv6 Canon MG7700 series Secure Internet Printer local
+ (null) IPv4 Canon MG7700 series Secure Internet Printer local
+ (null) IPv6 Canon MG7700 series _scanner._tcp local
+ (null) IPv4 Canon MG7700 series _scanner._tcp local
+ (null) IPv6 Canon MG7700 series Internet Printer local
+ (null) IPv4 Canon MG7700 series Internet Printer local
+ (null) IPv6 Canon MG7700 series UNIX Printer local
+ (null) IPv4 Canon MG7700 series UNIX Printer local
+ (null) IPv4 Canon MG7700 series Web Site local
+ (null) IPv4 Canon MG7700 series _canon-bjnp1._tcp local
+ (null) IPv4 Canon MG7700 series _privet._tcp local
+ (null) IPv6 Canon MG7700 series Web Site local
+ (null) IPv6 Canon MG7700 series _canon-bjnp1._tcp local
+ (null) IPv6 Canon MG7700 series _privet._tcp local
I'm curious to why the network interface column is showing (null) and whether there's a way to actually show the proper interface (wlan0, eth0, etc.).
英文:
I'm attempting mDNS discovery from within a Docker container and running it using
sudo docker run --privileged -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -d -p 5001:5001 my_application
as shown in this post
When running avahi-browse within the container, I get this output:
root@38ca93e44ce1:/etc/avahi# avahi-browse -a
+ (null) IPv4 amzn.dmgr:2A9009CCFEAFDF82846897DD0D687295:xnVDMM+4u1:767308 Amazon Fire TV local
+ (null) IPv6 Canon MG7700 series _uscan._tcp local
+ (null) IPv4 Canon MG7700 series _uscan._tcp local
+ (null) IPv6 Canon MG7700 series Secure Internet Printer local
+ (null) IPv4 Canon MG7700 series Secure Internet Printer local
+ (null) IPv6 Canon MG7700 series _scanner._tcp local
+ (null) IPv4 Canon MG7700 series _scanner._tcp local
+ (null) IPv6 Canon MG7700 series Internet Printer local
+ (null) IPv4 Canon MG7700 series Internet Printer local
+ (null) IPv6 Canon MG7700 series UNIX Printer local
+ (null) IPv4 Canon MG7700 series UNIX Printer local
+ (null) IPv4 Canon MG7700 series Web Site local
+ (null) IPv4 Canon MG7700 series _canon-bjnp1._tcp local
+ (null) IPv4 Canon MG7700 series _privet._tcp local
+ (null) IPv6 Canon MG7700 series Web Site local
+ (null) IPv6 Canon MG7700 series _canon-bjnp1._tcp local
+ (null) IPv6 Canon MG7700 series _privet._tcp local
I'm curious to why the network interface column is showing (null) and whether there's a way to actually show the proper interface (wlan0, eth0, etc.)
答案1
得分: 1
您之所以在网络接口上看到(null)
,是因为容器在一个隔离的网络命名空间中运行,它无法访问主机接口。
您可以通过在主机网络命名空间中运行(使用--net=host
,这要求您放弃-p
选项),从而让容器能够访问主机网络环境,来解决这个问题。
至少在我的测试中,在这两种情况下似乎都不需要运行一个--privileged
容器。
英文:
You're seeing (null)
for the network interface because the container is running in an isolated network namespace -- it doesn't have any access to the host interfaces.
You could resolve this by running in the host network namespace (--net=host
, which requires you to drop the -p
option), which gives the container access to the host network environment.
At least in my testing, running a --privileged
container doesn't appear to be necessary in either situation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论