本人电脑mac,m1芯片,新手入门docker。在使用docker拉去ros:noetic时,dockerfile文件如下
FROM ros:noetic-ros-base
# Set the environment variables to prevent interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive
# Update the package list and install required packages
RUN apt-get update && apt-get install -y \
python3-osrf-pycommon \
python3-catkin-tools \
ros-noetic-rviz \
ros-noetic-gazebo-ros-pkgs
# Create a catkin workspace
RUN mkdir -p /catkin_ws/src && \
cd /catkin_ws && \
catkin_make
# Source the workspace setup.bash file
RUN echo "source /catkin_ws/devel/setup.bash" >> /root/.bashrc
随后执行(base) docker build -t ros-noetic-arm64 .
报错代码如下
> [3/4] RUN mkdir -p /catkin_ws/src && cd /catkin_ws && catkin_make:
0.127 /bin/sh: 1: catkin_make: not found
------
Dockerfile:14
--------------------
13 | # Create a catkin workspace
14 | >>> RUN mkdir -p /catkin_ws/src && \
15 | >>> cd /catkin_ws && \
16 | >>> catkin_make
17 |
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p /catkin_ws/src && cd /catkin_ws && catkin_make" did not complete successfully: exit code: 127
这是什么原因,我该如何修改,感谢
【以下回答由 GPT 生成】
问题原因是在Dockerfile中的第14行尝试运行catkin_make
命令时出错,提示找不到该命令。
这个问题可能是由于在执行catkin_make
之前,没有安装构建工具和ROS相关的依赖项导致的。
为了解决这个问题,你可以在Dockerfile中添加安装构建工具和ROS依赖项的步骤。更新后的Dockerfile如下所示:
FROM ros:noetic-ros-base
# Set the environment variables to prevent interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive
# Update the package list and install required packages
RUN apt-get update && apt-get install -y \
python3-osrf-pycommon \
python3-catkin-tools \
ros-noetic-rviz \
ros-noetic-gazebo-ros-pkgs \
build-essential
# Create a catkin workspace
RUN mkdir -p /catkin_ws/src && \
cd /catkin_ws && \
catkin_make
# Source the workspace setup.bash file
RUN echo "source /catkin_ws/devel/setup.bash" >> /root/.bashrc
更新后的Dockerfile中,我添加了build-essential
包的安装,这是基本的构建工具。
现在,重新执行docker build -t ros-noetic-arm64 .
命令,它应该能够成功构建Docker映像,解决这个问题。
请注意,由于你使用的是Mac电脑,需要确保已经正确地安装和配置了Docker Desktop for Mac。