Connecting between bridge containers and host containers

I have a set of containers created from the TeslaMate installation – Teslamate, Grafana, Mosquitto and Database. All four of these containers are connected to a “docker_default” bridge network. All four of these containers are communicating with each other wonderfully.

I also have a separate Host container running the latest version of NodeRed. I need this container to be a host container so that it can interact with devices on my local network. I would like to get NodeRed to be able to connect with the Mosquitto container, but cannot figure out how.

All suggestions would be much appreciated!

What do you mean by “host container”? Is it a container using the host network instead of a Docker bridge?

Yes, sorry – a container using the “Host” network.

I’m basically wanting to have the NodeRed container be in the Host network as well as the docker_default network so it can communicate with my local network as well as my docker containers.

It is not posible. Docker networks are network namespaces to isolate your container and have a “virtual” network for your container. If you use the host network, it means you don’t want to use network namespaces, so you don’t want that isolation. You can publish the ports of the target containers or set static ip addresses for those containers so you can refer to them using IP addresses.

What interaction do you need? You should be able to access other devices on your LAN network from a container.

Okay, thanks for the clear answer. I was finding lots of conflicting info on the web.

As far as the interactions, I’m trying to be able to run Ping from my NodeRed container and ping devices on my home network (outside of docker). I need a HOST network container to do that, right?

If the NodeRed container should ping a target within the same container network or your LAN network, it doesn’t require --network=host.

Note: when the container is in a bridge network, NodeRed will not be able to receive multicast traffic from the LAN network (which is typically used by discovery protocols).

I didn’t have time to find this topic again, but fortunately you didn’t have to wait for me :slight_smile: Just an example: Your computer is probably not in the same network as the servers of Google, but you can still access them. Even if you use host network, Docker Desktop will still have its own private network and the host network means the network of the virtual machine of Docker Desktop.