ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

how to conect with roscore in docker?

asked 2019-07-26 01:50:10 -0600

yueweiliang gravatar image

As titles, how can I running a roscore in docker with ROS_MASTER_URI=XX.X.X.X. And make the nodes outside docker can connect with the docker roscore using specified ROS_MASTER_URI?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-26 05:25:43 -0600

alsora gravatar image

updated 2019-07-26 05:50:15 -0600

I think that you misunderstood the role of the environment variable ROS_MASTER_URI. If you have the ROS MASTER and a ROS NODE, the variable will be used by the ROS NODE to know where to look for the MASTER. It's not setting the master URI to a specific value.

In your example, you should just run roscore in the Docker, without setting any environment variable. roscore will print to screen the URI where the master can be reached.

In the terminal where you want to run your nodes, you will have to run export ROS_MASTER_URI=XX.X.X.X with the URI that has been previously printed.

Moreover, if using Docker, you should make sure that the Docker container has not been run in isolated mode.

edit flag offensive delete link more


I have not been able to get this to work. I am using a Docker within WSL 2. I run the docker with the command:

docker run -it --network=host ros:noetic-ros-base

Then typing: hostname -I, I get two IP addresses:

Then I do export ROS_MASTER_URI=, and run roscore in the docker, and am unable to see it from outside the docker. Similarly if I use the other IP address.

I have not been able to find any way to make roscore visible outside the docker

Morris gravatar image Morris  ( 2020-10-13 20:34:38 -0600 )edit

Question Tools



Asked: 2019-07-26 01:50:10 -0600

Seen: 3,641 times

Last updated: Jul 26 '19