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

huangapple go评论47阅读模式
英文:

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

问题

在上述情况下,我的服务器无法读取和写入服务器上的任何目录,尽管目录存在,但它显示没有这样的文件或目录打开,并显示错误。而在我的本地系统上,它运行正常。

英文:

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

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

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.

huangapple
  • 本文由 发表于 2023年7月10日 18:51:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76652998.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定