how to make ROS truly containerized in Docker?
I have a linux server that multiple developers access for development where X11 Forwarding is used for remote GUI.
I have a functioning Docker Container where I can roslaunch Gazebo and RViz and load a model.
The problem is... ROS does not appear to be truly containerized. Meaning, when two developers each launch their own container (built from the same Dockerfile) and launch Gazebo/Rviz then cross-talk is experienced. Meaning, a robot model from Developer A shows up in the Gazebo of Developer B in addition to their own robot model.
We have tried setting ROS_MASTER_URI to unique values between the two developers:
export ROS_MASTER_URI=http://127.0.0.1:$PORT
- Dev A --> PORT = 11311
- Dev B --> PORT = 11312
likewise, roscore was launched with the unique ports
roscore --port $PORT >/dev/null 2>&1 &
but we still get cross-talk.
How is it possible to configure a ROS such that two containers (performing the same gazebo simulation) can truly be isolated/containerized?
System: Ubuntu 18.04, ROS-melodic, Gazebo9, Docker 19.03.12
I recommend to run both containers with non standard ros ports (not 11311) and try again. Thus no one ros app will start without properly set ROS_MASTER_URI variable. Check if you have cross access using rostopic command. I'm using kinetic and I can fully separate two environments using the approach you proposed even without container (in rviz I have no cross access to topic).
As @dtyugin mentions, this is supported. Just treat each container as a host on the network.
If you really want to isolate things: don't use the
host
network and don't map any ports from the container to the host.Thanks for the comments.
@gvdhoorn, not using the host network takes away my ability to X11 Forward (which I'm dependent upon right now... COVID).
@dtyugin, I retested today with,
export ROS_MASTER_URI=http://127.0.0.1:$PORT Dev A --> PORT = 11311 Dev B --> PORT = 11312 roscore --port $PORT >/dev/null 2>&1 &
as descripted above and things are now working. It seems that I had a faulty set of tests yesterday.
Thanks again to you both.
I'm pretty sure this would work without the
host
network, but instead using bridged networking with separate IPs per container. That's how I really isolate containers.