Docker:复制失败:stat <file>:文件不存在

Docker: COPY failed: stat <file>: file does not exist

我正在尝试将文件复制到我的 docker 容器中,但命令失败。文件和Dockerfile在同一个目录下,不明白错误原因

如果有任何帮助或建议,我将不胜感激。预先感谢。

这是代码:

FROM ubuntu:20.04 as builder
ENV DEBIAN_FRONTEND=noninteractive 

RUN apt-get update
RUN apt-get install -y \
    build-essential \
    cmake \
    software-properties-common \
    libopencv-dev

RUN add-apt-repository -y ppa:chrberger/libcluon
RUN apt-get update
RUN apt-get install -y libcluon

ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir build && \
    cd build && \
    cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/dest .. && \
    make && make install


FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive 

RUN apt-get update --fix-missing
RUN apt-get install -y \
    libopencv-core4.2 \
    libopencv-imgproc4.2 \
    libopencv-video4.2 \
    libopencv-calib3d4.2 \
    libopencv-features2d4.2 \
    libopencv-objdetect4.2 \
    libopencv-highgui4.2 \
    libopencv-videoio4.2 \
    libopencv-flann4.2 \
    libopencv-dnn-dev \
    python3-opencv

WORKDIR /usr/bin
COPY --from=builder /tmp/dest /usr
COPY --from=builder yolov3-tiny_obj.cfg /params
ENTRYPOINT ["/usr/bin/opendlv-perception-helloworld"]

能否说明您的 Dockerfile 中的哪一行导致了错误消息?

您尝试从工作目录复制的文件是 yolov3-tiny_obj.cfg

如果是这样,它会失败,因为您指定从 builder 阶段复制它。 该行可能看起来像这样:

COPY yolov3-tiny_obj.cfg /params