Rosanswers logo

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

Originally posted by kk2105 on ROS Answers with karma: 262 on 2019-03-20

Post score: 1

Original comments

Comment by fvd on 2019-03-20:
Can you summarize the problem and what you're trying to do? This question doesn't stand on its own as is.

Comment by kk2105 on 2019-03-20:
Apologies, I will elaborate the issue. I have updated the question. Thank you.

Comment by dljubic on 2019-03-23:
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?

Comment by kk2105 on 2019-03-25:
@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.


1 Answer 1


Rosanswers logo

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!

Originally posted by dljubic with karma: 516 on 2019-04-02

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by kk2105 on 2019-04-03:
@dljubic Sorry for the delayed reply. Thanks for the answer. I will try this out and update you here.


Your Answer

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