[英]Docker - No such file or directory when running the image
FROM python:3.10
COPY requirements.txt .
RUN pip install -r requirements.txt
#Make a copy of the current directory
COPY / ./
#Display list of files in directory
RUN ls /
ENTRYPOINT ["python", "/main.py"]
So this is my current dockerfile and the list displays as this when I build.所以这是我当前的 dockerfile 并且在我构建时列表显示为这个。 Directory List
目录列表
This is the code that is giving me the issue这是给我问题的代码
d1 = open(r"backend_resources\results\orlando_averaged_2019-01-01.geojson")
And throwing me this error when I run the image当我运行图像时抛出这个错误
FileNotFoundError: [Errno 2] No such file or directory: 'backend_resources\\results\\orlando_averaged_2019-01-01.geojson'
However you will notice that in the image with the list, backend_resources and the other files within it do exist, and to my knowledge are in the correct directories for this code to run properly, still new to Docker so I definitely could be doing something wrong但是您会注意到,在带有列表的图像中,backend_resources 和其中的其他文件确实存在,据我所知,这些文件位于正确的目录中,以便此代码正常运行,对于 Docker 来说仍然是新的,所以我肯定可能做错了什么
I think problem is chosen path style.我认为问题是选择的路径样式。 You use path in windows style.
您使用 windows 样式的路径。 If you image based on unix system (Debian, Alpine, etc.), use path in unix style.
如果您的映像基于 unix 系统(Debian、Alpine 等),请使用 unix 样式的路径。
d1 = open(r"/backend_resources/results/orlando_averaged_2019-01-01.geojson")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.