Rosanswers logo

I would like to know how to set up connection between ROS in Docker with ROS on host PC correctly.
Following some answers like these [1][2] I can understand that connecting container to host network and exporting proper environmental variables should be enough.
However, when I try pub/echo between container and host PC, I get no response

Here is how I start everything:
On host PC I have the following in my .bashrc:


Then I start roscore in the first terminal. In the second terminal I run:
docker run --net=host --name ros-test -it --rm osrf/ros:noetic-desktop

And in the resulting second terminal I export the same environmental variables as shown above. Then I inspect available topics with rostopic list and can see default topics when roscore in running:


Then in the third terminal from host PC I try simple publish command:
rostopic pub -r 1 /test std_msgs/String "halo"

Then try to receive messages in the container which is the second terminal: rostopic echo /test I expect to receive messages, but there is nothing coming. When I do rostopic hz /test, it says "no new messages"
When I check rostopic info /test from fourth terminal I get the folllowing:

Type: std_msgs/String

  • /rostopic_178825_1670943581897 (http://risc-SYS-5049A-TR:33815/)
  • /rostopic_111_1670945011845 (http://docker-desktop:57739/)

With publisher being my third terminal and subscriber being my second terminal which is container

Is there something wrong with how I am doing things? Please advise or help

Originally posted by akim on ROS Answers with karma: 11 on 2022-12-13

Post score: 1


1 Answer 1


Rosanswers logo

So I figured out it was my dumb mistake
I was following these instructions, but, apparently, I somehow skipped step (3) and didn't activate group changes. Now when I did, everything seems to work

Originally posted by akim with karma: 11 on 2022-12-20

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.