Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to have topics publish and subscribe both ways between host and docker container?

I have roscore running in docker. I have a bunch of topics, some are started by nodes inside the docker container, some are outside of the container, on host. I need some of these topics to subscribe to eachother. I can subscribe from host to topics that are inside docker and I can echo what's being published to them. But in the container I can't echo topics that are published on host.

For example, what I can do:
Inside docker: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
On host: rostopic echo /dummy and I see dummy text being printed

What I can't do:
On host: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
Inside docker: rostopic echo /dummy dummy text should be printed, but nothing is coming out

What I have tried:

  • --net=host, -e ROS_IP=172.17.0.1 and -e ROS_MASTER_URI=http://172.17.0.1:11311 in in docker run which made the first part work (publish topic in docker and echo from host)
  • modifiy /etc/hosts in docker container and on host
  • all sorts of combinations for ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME
  • running roscore on host and setting ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME accordingly

I followed many tutorials, many involving ROS_IP and ROS_MASTER_URI. I've tried filling these 2 in many different combination using addresses provided by ip a s, nothing made it work.

rostopic list works fine on host and in docker no matter where roscore runs. I can ping host from docker and vice versa. I also tested with netcat, both ways works fine, yet topics don't want to send data from host to docker.

How to have topics publish and subscribe both ways between host and docker container?

I have roscore running in docker. I have a bunch of topics, some are started by nodes inside the docker container, some are outside of the container, on host. I need some of these topics to subscribe to eachother. I can subscribe from host to topics that are inside docker and I can echo what's being published to them. But in the container I can't echo topics that are published on host.

For example, what I can do:
Inside docker: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
On host: rostopic echo /dummy and I see dummy text being printed

What I can't do:
On host: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
Inside docker: rostopic echo /dummy dummy text should be printed, but nothing is coming out

What I have tried:

  • --net=host, -e ROS_IP=172.17.0.1 and -e ROS_MASTER_URI=http://172.17.0.1:11311 in in docker run which made the first part work (publish topic in docker and echo from host)
  • modifiy /etc/hosts in docker container and on host
  • all sorts of combinations for ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME
  • running roscore on host and setting ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME accordingly

I followed many tutorials, many involving ROS_IP and ROS_MASTER_URI. I've tried filling these 2 in many different combination using addresses provided by ip a s, nothing made it work.

rostopic list works fine on host and in docker no matter where roscore runs. I can ping host from docker and vice versa. I also tested with netcat, both ways works fine, yet topics don't want to send data from host to docker.

In docker I have ros indigo and on host I have melodic, maybe that is a problem?

How to have topics publish and subscribe both ways between host and docker container?

I have roscore running in docker. I have a bunch of topics, some are started by nodes inside the docker container, some are outside of the container, on host. I need some of these topics to subscribe to eachother. I can subscribe from host to topics that are inside docker and I can echo what's being published to them. But in the container I can't echo topics that are published on host.

For example, what I can do:
Inside docker: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
On host: rostopic echo /dummy and I see dummy text being printed

What I can't do:
On host: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
Inside docker: rostopic echo /dummy dummy text should be printed, but nothing is coming out

What I have tried:

  • --net=host, -e ROS_IP=172.17.0.1 and -e ROS_MASTER_URI=http://172.17.0.1:11311 in in docker run which made the first part work (publish topic in docker and echo from host)
  • modifiy /etc/hosts in docker container and on host
  • all sorts of combinations for ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME
  • running roscore on host and setting ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME accordingly

rostopic list works fine on host and in docker no matter where roscore runs. I can ping host from docker and vice versa. I also tested with netcat, both ways works fine, yet topics don't want to send data from host to docker.

In docker I have ros indigo and on host I have melodic, maybe (I can't decide what ros version is used) and on host I have melodic (I can install indigo if anyone thinks that is might a problem?problem).

How to have topics publish and subscribe both ways between host and docker container?

I have roscore running in docker. I have a bunch of topics, some are started by nodes inside the docker container, some are outside of the container, on host. I need some of these topics to subscribe to eachother. I can subscribe from host to topics that are inside docker and I can echo what's being published to them. But in the container I can't echo topics that are published on host.

For example, what I can do:
Inside docker: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
On host: rostopic echo /dummy and I see dummy text being printed

What I can't do:
On host: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
Inside docker: rostopic echo /dummy dummy text should be printed, but nothing is coming out

What I have tried:

  • --net=host, -e ROS_IP=172.17.0.1 and -e ROS_MASTER_URI=http://172.17.0.1:11311 in in docker run which made the first part work (publish topic in docker and echo from host)
  • modifiy /etc/hosts in docker container and on host
  • all sorts of combinations for ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME
  • running roscore on host and setting ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME accordingly

rostopic list works fine on host and in docker no matter where roscore runs. I can ping host from docker and vice versa. I also tested with netcat, both ways works fine, yet topics don't want to send data from host to docker.

In docker I have ros indigo (I can't decide what ros version is used) and on host I have melodic (I can install indigo if anyone thinks that might a problem).

UPDATE:

By using --net=host, ROS_IP=127.0.0.1 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.

How to have topics publish and subscribe both ways between host and docker container?

I have roscore running in docker. I have a bunch of topics, some are started by nodes inside the docker container, some are outside of the container, on host. I need some of these topics to subscribe to eachother. I can subscribe from host to topics that are inside docker and I can echo what's being published to them. But in the container I can't echo topics that are published on host.

For example, what I can do:
Inside docker: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
On host: rostopic echo /dummy and I see dummy text being printed

What I can't do:
On host: rostopic pub /dummy std_msgs/String "data: 'dummy text'" -r 10
Inside docker: rostopic echo /dummy dummy text should be printed, but nothing is coming out

What I have tried:

  • --net=host, -e ROS_IP=172.17.0.1 and -e ROS_MASTER_URI=http://172.17.0.1:11311 in in docker run which made the first part work (publish topic in docker and echo from host)
  • modifiy /etc/hosts in docker container and on host
  • all sorts of combinations for ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME
  • running roscore on host and setting ROS_IP, ROS_MASTER_URI and ROS_HOSTNAME accordingly

rostopic list works fine on host and in docker no matter where roscore runs. I can ping host from docker and vice versa. I also tested with netcat, both ways works fine, yet topics don't want to send data from host to docker.

In docker I have ros indigo (I can't decide what ros version is used) and on host I have melodic (I can install indigo if anyone thinks that might a problem).

UPDATE:

UPDATE:
By using --net=host, ROS_IP=127.0.0.1 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.