How to run a ROS2 node inside docker image?

asked 2022-10-04 23:24:49 -0500

Astronaut gravatar image

updated 2022-10-05 04:34:26 -0500

ravijoshi gravatar image

Hi

I have a ROS 2 package and successfully create a docker image of it. Then when inside the container I would like to run only one single node of the ROS 2 package. So first I create the environment with PATH=$PATH:/home/user/.local/bin then vcs import . <system_integration/ros.repos then docker pull ghcr.io/test-inc/base_images:foxy. I am running and executing the docker with

docker run --name test -d --rm -v $(pwd):/home/ros2/foxy/src ghcr.io/company-inc/robot1_vnc_ros2:foxy

docker exec -it test /bin/bash

Then when I am inside the docker. I build the package with

colcon build --symlink-install --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to system_integration

So now I am inside the docker in the root@1942eef8d977:~/ros2/foxy and would like to run one python node. But ros2 run package_name node_name would not work right? I am not familiar much with docker so not sure how to run the node. Any help?

Thanks

edit retag flag offensive close merge delete

Comments

... ros2 run package_name node_name would not work right? ...

Please try it first. Then, if it does not work, you can post the errors.

ravijoshi gravatar image ravijoshi  ( 2022-10-05 04:35:26 -0500 )edit