英文:
Why my DockerFile is unable to read and write data to any directory on server even it exists, while locally working ok on my system
问题
在上述情况下,我的服务器无法读取和写入服务器上的任何目录,尽管目录存在,但它显示没有这样的文件或目录打开,并显示错误。而在我的本地系统上,它运行正常。
英文:
In the above my server is unable to read and write data to any directory on server while directory exists but it shows no such file or directory open and error shows. While it's working ok on my system locally.
答案1
得分: 0
当您使用 -v /home/hali/Downloads/thumbnail:/src/app
将主机上的目录映射到容器时,该目录将在容器内的路径 /src/app
处可访问。
您的程序期望在 /home/hali/Downloads/thumbnail
处找到它,因此它无法正常工作。
您可以以两种方式修复它:
- 更改程序以将缩略图写入
/src/app
。 - 更改容器内映射到的目录名称。如果您使用
-v /home/hail/Downloads/thumbnail:/home/hail/Downloads/thumbnail
进行映射,该目录在容器内将与容器外部相同的名称下知道。
英文:
When you bind map a directory on the host into a container using -v /home/hali/Downloads/thumbnail:/src/app
, the directory will be accessible inside the container on the path /src/app
.
Your program expects to find it at /home/hali/Downloads/thumbnail
, so it doesn't work.
You can fix it in two ways:
- Change the program to write the thumbnails to
/src/app
. - Change the name the directory is mapped to inside the container. If you map it using
-v /home/hail/Downloads/thumbnail:/home/hail/Downloads/thumbnail
the directory will be known under the same name inside the container as it is outside the container.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论