Ask Your Question

Communication between docker and host

asked 2019-03-20 06:10:18 -0500

kk2105 gravatar image

updated 2019-03-25 09:26:21 -0500

Hi Guys,

This is with respect to the q313094, I was able to get rid of the /use_sim_time is not set, will not subscribe to simulated time [/clock] topic error by following the steps given in link.

However as mentioned in the answer, I always need to run the subscriber first then start publishing the message. If I start publishing first then subscriber it doesn't work.

Could you please let me know is there a way I can fix this, so that I can subscribe to the message anytime?

Problem description:
I have an application which is running inside the docker (Apollo - autonomous driving platform) which uses ros for message communication, I want to create custom messages in my host system and publish to the apollo platform inside docker. For testing purpose I just published simple message by running rostopic pub -r 10 /test_topic std_msgs/String "hello....". This did not work as I was getting error /use_sim_time is not set, will not subscribe to simulated time [/clock] topic. This was fixed by By using --net=host, ROS_IP= and ROS_MASTER_URI=http://localhost:11311 and running the subscriber from docker before the publisher from host I got it working. But this means subscriber must always run before publisher for my scripts to work.

Update 1: @dljubic Please find the details given below:

Outside the docker container:

echo $ROS_MASTER_URI - http://localhost:11311
echo $ROS_HOSTNAME   - empty
echo $ROS_IP         - empty

Inside the docker container:

echo $ROS_HOSTNAME   - empty
echo $ROS_IP         -

Thank you, KK

edit retag flag offensive close merge delete


Can you summarize the problem and what you're trying to do? This question doesn't stand on its own as is.

fvd gravatar image fvd  ( 2019-03-20 06:51:22 -0500 )edit

Apologies, I will elaborate the issue. I have updated the question. Thank you.

kk2105 gravatar image kk2105  ( 2019-03-20 07:03:32 -0500 )edit

Cloud you please provide the output of echo $ROS_MASTER_URI, echo $ROS_HOSTNAME and echo $ROS_IP on your host i.e. outside of a Docker container and inside a Docker container?

dljubic gravatar image dljubic  ( 2019-03-23 16:29:32 -0500 )edit

@dljubic I have updated the question with the details (inside and outside docker container). I am not seeing any output for HOSTNAME and IP outside the docker.

kk2105 gravatar image kk2105  ( 2019-03-25 09:18:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-04-02 09:53:29 -0500

dljubic gravatar image

Hello kk2105,

I can share the configuration that always works for me. First, I start roscore outside a docker container. Locally, and in docker container, I have the following in my ~/.bashrc:

export ROS_MASTER_URI=http://$(hostname --ip-address):11311
export ROS_HOSTNAME=$(hostname --ip-address)

Caveat: docker container was created with a --network host flag.

Please try that configuration and let me know if it helps!

edit flag offensive delete link more


@dljubic Sorry for the delayed reply. Thanks for the answer. I will try this out and update you here.

kk2105 gravatar image kk2105  ( 2019-04-03 21:56:22 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-03-20 06:10:18 -0500

Seen: 1,173 times

Last updated: Apr 02 '19