简体   繁体   English

Docker - 运行图像时没有这样的文件或目录

[英]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.

相关问题 运行Docker容器时没有此类文件或目录错误 - No such file or directory error when running Docker container 构建 Docker 映像时“没有此类文件或目录” - “No such file or directory” when building Docker image 在Docker容器中运行命令时出现奇怪的“无此类文件或目录”错误 - Bizarre “No such file or directory” error when running a command within a docker container 在docker上运行时,Python烧瓶重新加载器“Errno 2没有这样的文件或目录”错误 - Python flask reloader “Errno 2 No such file or directory” error when running on docker 在docker上运行uwsgi不会导致此类文件或目录 - running uwsgi on docker causing no such file or directory Docker 运行 Python 错误 - [错误 2] 没有这样的文件或目录 - Docker Running Python Error - [Error 2] No such file or directory 致命错误:* .h:没有这样的文件或目录。 在运行docker build命令时为python项目创建映像 - fatal error: *.h: No such file or directory. While running docker build command to create image for python project 没有这样的文件或目录,在 .net core 中运行控制台应用程序时无法在 docker 容器中找到 Python.exe - No such file or directory, Unable to find Python.exe in docker container when running console app in .net core Docker:尝试在Docker中运行Docker时没有此类文件或目录 - Docker: No such file or directory when trying to run docker inside docker 在tensorflow docker镜像上启动convolutional.py脚本时,“没有这样的文件或目录” - “No such file or directory” when starting convolutional.py script on tensorflow docker image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM