Ask Your Question

Is ROS already sourced if I do it from a dockerfile?

asked 2020-07-03 19:44:23 -0500

Kansai gravatar image

updated 2020-07-12 01:23:28 -0500

I am currently building a dockerfile based on ROS. So far it is going great. However I have a doubt.

In a native installation I have to source $ROS_DISTRO/setup.bash every time I open a terminal. It is advised to put the line into the bashrc so that it gets executed automatically every time I open a terminal.

I wanted to do something similar for the dockerfile so I put a shell script and try to execute it (source the bash) every time I join the container.

However I found later that once I build the ROS container, it has s file called that has the line source "opt/ros/$ROS_DISTRO/setup.bash". Furthermore once I run the container, I can call roscore so that means that got executed already

Is this correct? What for is this script?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-09 16:57:47 -0500

ruffsl gravatar image

What for is this script?

This is the default endpoint for all official library ROS docker images, and simple sources the setup script. This is why you can simply pass ros commands like roslaunch or rosrun in the docker run command.

Note that this endpoint isn't executed at build time, so RUN directives in the Dockerfile that expect the ROS environment to be sourced, e.g. chaining colcon workspaces or running rosdep, will have to source the setup script for that RUN directive. Each RUN directive run's in its own env, asside from the global ENV and ARG the scope over later layers.

Note that if you use docker exec to open a new shell in a ros container, that the default entry-point from the original docker image/file will not sourced automatically like for docker run. So for that, you could source it manually after launch the shell, or add it to the .bashrc for the default user (normally root) in the docker image, if you've passed bash to docker exec.

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: 2020-07-03 19:44:23 -0500

Seen: 412 times

Last updated: Jul 12 '20