【发布时间】:2020-12-02 22:31:04
【问题描述】:
我正在按照 dockerfile 中http://wiki.ros.org/noetic/Installation/Ubuntu 的说明安装 ROS。安装后,使用“source /opt/ros/noetic/setup.bash”设置环境。但是,在我这样做之后,dockerfile 中的每个 RUN 命令都会停止正常工作。
在下面的 dockerfile 中,第一个 'ls /' 会产生预期的输出,但第二个不会。这不是特定于“ls”的,这只是问题的演示;我在 ROS 环境后运行的每个命令都没有预期的效果。 ROS 环境设置中发生了什么来破坏它,我该如何防止它?在设置 ROS 后,我还有很多其他设置需要进行。
FROM ubuntu:20.04
# Dependencies
RUN apt-get update && apt-get install -y lsb-release && apt-get clean all
RUN apt-get install -y gnupg2
# Set timezone so tzdata is not interactive during install
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install ROS, from http://wiki.ros.org/noetic/Installation/Ubuntu
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
apt-get update && \
apt install -qq -y ros-noetic-ros-base
RUN apt-get install -y python3-pip
RUN python3 -m pip install rospkg
RUN echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
# This DOES produce what you would think
RUN ls /
SHELL ["/bin/bash", "-c", "source ~/.bashrc"]
# This DOES NOT produce what you would think
RUN ls /
【问题讨论】: