0

My program is consisting of a network of ROS1 and ROS2 nodes, which are software that work with a publish/subscribe way of communication.

Assume there is 4 nodes running inside a custom network: onboard_network.

Those 4 nodes (ROS1) can only communicate together, therefore we have a bridge node (ROS1 & ROS2) that needs to be sitting on the edge on both onboard_network and host network. The reason why we need the host network is because the host is inside a VPN (Zerotier). Inside the VPN we have also our server (ROS2).

We also need the bride node to work with host network because ROS2 work with some multicast stuff that works only on host mode.

So basically, I want a docker compose file running 4 containers inside an onboard_network & a container running inside the host network. The last container needs to be seen from the containers in the onboard_network and being able to see them too. How could I do it ? Is it even possible ?

sshmaxime
  • 499
  • 5
  • 15

1 Answers1

0

If you're running a container on the host network, its network setup is identical to a non-container process running on the host.

A container can't be set to use both host networking and Docker networking.

That means, for your network_mode: host container, it can call other containers using localhost as a hostname and their published ports: (because its network is the host's network). For your bridge-network containers, they can call the host-network container using the special hostname host.docker.internal on MacOS or Windows hosts, or on Linux they need to find some reachable IP address (this is discussed further in From inside of a Docker container, how do I connect to the localhost of the machine?.

David Maze
  • 130,717
  • 29
  • 175
  • 215