0

I'm experimenting for the first time to try to create a docker container to run ROS. I am getting a confusing error and I cant figure out how to trouble

bash-3.2$ docker run -ti --name turtlebot3 rosdocker To run a command
as administrator (user "root"), use "sudo <command>". See "man
sudo_root" for details.

bash: /home/ros/catkin_ws/devel/setup.bash: No such file or directory

I am creating rosdocker with this dockerfile, from inside vscode. I am using the Docker plugin and using the "Build Image" command. Here's the Dockerfile:

FROM ros:kinetic-robot-xenial

RUN apt-get update && apt-get install --assume-yes \sudo \
python-pip \
ros-kinetic-desktop-full \
ros-kinetic-turtlebot3 \
ros-kinetic-turtlebot3-bringup \
ros-kinetic-turtlebot3-description \
ros-kinetic-turtlebot3-fake \
ros-kinetic-turtlebot3-gazebo \
ros-kinetic-turtlebot3-msgs \
ros-kinetic-turtlebot3-navigation \
ros-kinetic-turtlebot3-simulations \
ros-kinetic-turtlebot3-slam \
ros-kinetic-turtlebot3-teleop

# install python packages
RUN pip install -U scikit-learn numpy scipy
RUN pip install --upgrade pip

# create non-root user
ENV USERNAME ros
RUN adduser --ingroup sudo --disabled-password --gecos "" --shell /bin/bash --home /home/$USERNAME $USERNAME
RUN bash -c 'echo $USERNAME:ros | chpasswd'
ENV HOME /home/$USERNAME
USER $USERNAME

# create catkin_ws
RUN mkdir /home/$USERNAME/catkin_ws
WORKDIR /home/$USERNAME/catkin_ws

# add catkin env
RUN echo 'source /opt/ros/kinetic/setup.bash' >> /home/$USERNAME/.bashrc
RUN echo 'source /home/$USERNAME/catkin_ws/devel/setup.bash' >> /home/$USERNAME/.bashrc

I am not sure where the error is coming from and I don't know how to debug or troubleshoot it. I would appreciate any pointers!

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
pitosalas
  • 10,286
  • 12
  • 72
  • 120

1 Answers1

1

You are creating an user ros and then in the last line doing this:

RUN echo 'source /home/$USERNAME/catkin_ws/devel/setup.bash' >> /home/$USERNAME/.bashrc

So obviously, system will look for "/home/ros/catkin_ws/devel/setup.bash" which is not created any where inside docker file.

Either create this file or if you are planning to mount from host to docker, then run with

docker run -ti --name turtlebot3 rosdocker -v sourcevolume:destinationvolume

ganeshragav
  • 8,695
  • 1
  • 16
  • 13
  • Thanks! That must be it. Within that this source is what’s outside the container, and the destination is inside, or vice versa? – pitosalas Jan 19 '19 at 12:20
  • 1
    Exactly right. Check this for single file mount which is required in your case: https://stackoverflow.com/questions/36549144/mounting-a-single-file-from-a-docker-data-volume-in-a-docker – ganeshragav Jan 19 '19 at 14:20