简体   繁体   English

从 docker 看不到本地蚊子

[英]Local mosquitto not visible from docker

I have a local mosquitto broker running on ubuntu with bind_address localhost .我有一个在 ubuntu 上使用bind_address localhost运行的本地蚊子代理。 If I try to access this broker from a docker container with node-red on the same host, it is not reachable.如果我尝试从节点红色同一主机上的一个码头工人容器访问该经纪人,这是可达。 If I don't bind mosquitto to localhost, all works well.如果我不将 mosquitto 绑定到本地主机,则一切正常。

What can I do to make mosquitto visible only on local machine but also accessible for local docker containers?我该怎么做才能使 mosquitto 仅在本地机器上可见,但本地 docker 容器也可以访问?

localhost in the docker container is not the same localhost as the machine running the Docker engine. localhost在搬运工容器是不一样的localhost与运行多克尔发动机的机器。

If you want to access the broker you will need to use the address of the host machine on the Docker virtual network (eg 172.17.0.1 bound to device docker0 is the default I think).如果您想访问代理,您将需要使用 Docker 虚拟网络上主机的地址(例如,绑定到设备 docker0 的 172.17.0.1 是我认为的默认值)。

You can keep the bind_address entry, but you will need to add a second listener entry for the address bound to the docker0 interface.您可以保留bind_address条目,但您需要为绑定到 docker0 接口的地址添加第二个listener条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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