如何解决来自容器的错误

时间:2019-01-19 03:59:34

标签: docker ros

我正在第一次尝试创建一个运行ROS的docker容器。我收到一个令人困惑的错误,我无法弄清楚怎么办

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

我正在从vscode内部使用此dockerfile创建rosdocker。我正在使用Docker插件并使用“构建映像”命令。这是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

我不确定错误是从哪里来的,我也不知道如何调试或解决错误。任何指针,我将不胜感激!

1 个答案:

答案 0 :(得分:1)

您正在创建用户ros,然后在最后一行中这样做:

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

因此,很明显,系统将查找“ /home/ros/catkin_ws/devel/setup.bash”,该文件未在docker文件中的任何位置创建。

要么创建此文件,要么计划从主机安装到docker,然后使用

运行

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