简体   繁体   中英

Error when building Dockerfile for a Python project

I have the following Dockerfile defined for one of my Python projects:

FROM     jfloff/alpine-python
RUN      mkdir -p /raspi_motion_detection/project
WORKDIR  /raspi_motion_detection/project
COPY     ./project/ $WORKDIR/
COPY     ./requirements.txt $WORKDIR/
CMD      ["python", "core/motion_detector.py --conf conf/conf.json"]

When I tried to build it, I get the following error:

COPY failed: stat /var/lib/docker/tmp/docker-builder037986958/project: no such file or directory

All I'm trying to do is to copy the python files that I have locally in the /raspi_motion_detection/project and mimic this folder structure in the Docker image. I guess I'm making a very silly mistake somewhere but not sure where. Can anyone please help me?

I think I figured out the mistake. I have to modify the following line in my Dockerfile:

COPY     ./ $WORKDIR/

instead of:

COPY     ./project/ $WORKDIR/

As I'm already in the .project folder when execting the docker build, I do not need that extra ./project folder referenced!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM