Nodes can't talk to host when running ROS2 in Docker on MacOS
I’m running ROS2 in docker container on MacOS. For ROS2, I basically modified the dockerfile and docker-compose files given here for ROS1: https://github.com/nebocleaning/mac-ros
ROS2 nodes as well as Rviz (through web browser using novnc) are running within the container with no issues. Current problem is that docker container can’t communicate with host machine. I have ROS2 nodes also running on MacOS host machine but nodes in the container can’t talk with them.
As far as I know, Docker creates a virtual network for the container and blocks all connection between the container and host machine. You can open particular ports when running the container but ROS2 is using multiple ports and port numbers are changing each time you run a new node.
So far, I tried running container with --network=host option but I can’t see topic published on host machine or vice a versa.
This might be a question about configuring Docker on MacOS but wondering if anybody had any experience on this?
You can try and use tools like netcat with various Docker/VM network configurations to verify full connectivity: http://wiki.ros.org/ROS/NetworkSetup