我正在编写一个 Dockerfile 来在我的 Windows 装备上运行 ROS,但我似乎无法得到这个 COPY 命令来复制到容器的用户根目录或那里的任何子目录。我已经尝试了一些事情,包括弄乱所有权。我知道文件很丑但仍在学习。不太确定这里的问题是什么。
此文件位于 /repos 目录旁边,其中包含一个 git repo,可以在 here(ros-noetic 分支)中找到。这也是我构建和运行容器的位置。
总体目标是让 roscore 运行(它一直是这样),然后用另一个终端执行并让 rosrun ros_essentials_cpp(节点名称)真正工作
# ros-noetic with other stuff added
FROM osrf/ros:noetic-desktop-full
SHELL ["/bin/bash", "-c"]
RUN apt update
RUN apt install -y git
RUN apt-get update && apt-get -y install cmake protobuf-compiler
RUN bash
RUN . /opt/ros/noetic/setup.bash && mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/ && chmod 777 src && catkin_make && . devel/setup.bash
RUN cd /
RUN mkdir /repos
COPY /repos ~/catkin_ws/src
RUN echo ". /opt/ros/noetic/setup.bash" >> ~/.bashrc
答案 0 :(得分:2)
将波浪号扩展到主目录是一个 shell 功能,显然 Dockerfile 的 <label for="productList">Show Products</label>
<select name="products" id="productList">
</select>
命令不支持该功能。您将文件放入一个名为 let productArray = [];
let dropdown = document.getElementById("productList");
dropdown.addEventListener("click", initializeList());
function initializeList(){
//initializing with an example
productArray.push("PROD1");
productArray.push("PROD2");
productArray.push("PROD3");
productArray.forEach( item => {
option = document.createElement("option");
option.text = item;
dropdown.appendChild(option)
});
}
的目录中,即您的容器映像可能包含如下内容:
COPY
由于 ~
的主目录始终为 ...
dr-xr-xr-x 13 root root 0 Jun 9 00:07 sys
drwxrwxrwt 7 root root 4096 Nov 13 2020 tmp
drwxr-xr-x 13 root root 4096 Nov 13 2020 usr
drwxr-xr-x 18 root root 4096 Nov 13 2020 var
drwxr-xr-x 2 root root 4096 Jun 9 00:07 ~ <--- !!!
,因此您可以使用:
root
答案 1 :(得分:0)
您需要注意 docker 上下文。
当您构建 docker 时,您正在添加构建镜像的路径。
如果您不在 /
文件夹中,您的 COPY /repos
命令将不起作用。
尝试更改 docker 上下文:
docker build /