ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ROS2 foxy publish/subscribe between Docker container and Windows host

asked 2021-01-20 02:06:44 -0600

anastasiaPan gravatar image

updated 2021-01-25 03:25:24 -0600

Currently I have ROS2 foxy on a docker container and what I want to do is to publish and subscribe from the container to Windows side and the other way around as well. The container runs the tag base (link text). The installation I followed for ros2 foxy on windows is the official one (link text). Right now I am testing with ros2 examples (minimal publisher and minimal subscriber (link text) . I have tried to do this between two separate containers and it just works out of the box. It works if I do it between my ubuntu container and ubuntu host.

  • Docker networking in Windows:

First I tried to do the following (the I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST section) and it successfully connected to the host. But when running the publisher and subscriber nodes nothing goes through.

  • I also tried to publish the port:

    docker run -p 7412 my_ros_container

  • eProsima configuration:

One thing I tried but didn't fix is to change the RMW_IMPLEMENTATION to eProsima (link text). It should be the default value though. Having said that I am not at all experienced with DDS.

set RMW_IMPLEMENTATION=rmw_fastrtps_cpp

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="">
    <participant profile_name="ROS2_profile" is_default_profile="true">
  • CycloneDDS configuration:

I also tried with Cyclone DDS setting it both in the ubuntu container and in my Windows system. And then I included:

<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="" xmlns:xsi="" xsi:schemaLocation="">
  <Domain id="any">
        <Peer address="host.docker.internal"/>

which also did not work but it produced a log file which I can copy paste as a comment if needed.

  • WSL2

I also tried this: but there is no default.conf in my container so I copied it under /etc. I also tried to replace host with host.docker.internal as suggested at:

So I created a default.conf as below:

server {
    listen       7412;
    listen  [::]:7412;
    server_name  host.docker.internal;

and run my image:

docker run --rm --net host --volume $PWD/default.conf:/etc/default.conf my_img

and when I try to communicate with curl it fails: curl
curl: (7) Failed to connect to port 7412: Connection refused

This is my Dockerfile in case it is of any use:

> FROM ros:foxy as base
> RUN apt-get update \
> ...
edit retag flag offensive close merge delete


Please edit your question with the full commands that you're running and any settings you've configured on you system relating to netowrking. This likely has to do with how you've configured your docker networking. @ruffsl suggested you look at for a potential issue if you're using WSL2.

tfoote gravatar image tfoote  ( 2021-01-25 02:22:07 -0600 )edit

Ok so I have updated my answer and I tried to be as thorough as possible.

anastasiaPan gravatar image anastasiaPan  ( 2021-01-25 03:26:13 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-01-28 05:24:04 -0600

anastasiaPan gravatar image
edit flag offensive delete link more

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: 2021-01-20 02:06:44 -0600

Seen: 1,102 times

Last updated: Jan 28 '21