Search code examples
dockeropencvubuntudockerfileyolo

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


I am trying to copy a file into my docker container but the command fails. The file is in the same directory as the Dockerfile, so I don't understand the reason for the error.

I'd appreciate any help or advice. Thanks beforehand.

This is the code:

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"]

Solution

  • Could you please clarify which line in your Dockerfile causes the error message?

    Is the file you are trying to copy from your working directory yolov3-tiny_obj.cfg?

    If that is the case, it fails because you specify to copy it from the builder stage. The line should probably look like this:

    COPY yolov3-tiny_obj.cfg /params