I have Sonoma 14.2 on my M1-Max and can not make it run for talker/listener couple of ROS2 in docker container

I followed steps at here

Talker sends messages but no response from listener.

How should I discover the issue ?

I am running talker/listener in same container and not giving any config definition for startup

docker run -it osrf/ros:iron-desktop

in docker shell :

ros2 run demo_nodes_cpp listener &

ros2 run demo_nodes_cpp talker

  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Dec 15, 2023 at 8:57

1 Answer 1


When you start your Docker ROS container are you telling it --net=host ?

This is my start ROS 2 Docker (on Raspberry Pi5 but you'll get the idea):


cd ~/pi5desk/ros2ws
# --rm removes container after exit
# --w working dir to start in
docker run -it --net=host  -v /home/pi:/home/pi -w /home/pi/pi5desk/ros2ws --rm r2hdp
echo -e "\n*** EXITED DOCKER ***"

If you used the first example - it should have worked.

ros2 run demo_nodes_cpp listener &
ros2 run demo_nodes_cpp talker

Did it?

Did you start the Docker container detached and connect two terminal sessions to the same container? (That should have worked without needing a network.)

If you started two docker containers interactively, without specifying a network - the two containers cannot see each other. That will not work.

Please clarify exactly your sequence of commands to start docker, and run the talker and listener.

  • $\begingroup$ After adding the parameter --net=host it is completely working but why this is required although everything is happening within the container. Thanks $\endgroup$
    – serkan
    Commented Dec 16, 2023 at 15:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.