Docker挂载绑定类型配置无效:绑定源路径不存在

85次阅读
没有评论

问题描述

在使用Docker时遇到了一个问题。他有一个数据集存储在/vms1/thoth/new_maplab_shared目录下,但是当他尝试运行以下命令时:

$ docker run -it --mount type=bind,source=/vms1/thoth/new_maplab_shared,target=/new_maplab_shared edd5afa10b5f

他遇到了以下错误:

docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /vms1/thoth/new_maplab_shared.

用户明确指出目录是存在的。当他尝试使用以下命令时,它可以正常工作:

# mount -o bind /vms1/thoth/new_maplab_shared /home/new_maplab_shared
$ docker run -it --mount type=bind,source=/home/new_maplab_shared,target=/new_maplab_shared edd5afa10b5f

用户想知道出现了什么问题,并且如何在主机上消除绑定挂载的问题。

解决方案

请注意以下操作注意版本差异及修改前做好备份。

方案1

根据用户的描述,问题可能是由于Docker以Snap方式安装导致的。Snap是一种隔离层,类似于容器,它阻止对整个主机文件系统的访问。用户的主目录被挂载到Snap中,这样您就可以访问这些文件夹。如果您在Snap之外安装Docker,您应该可以访问将其他主机目录挂载到容器中。

方案2

用户在寻找给他的docker Snap访问该目录的方法时,发现了一些其他的StackExchange问题,这些问题让他相信目前可能无法实现这一点。您可以参考以下链接了解更多信息:
https://askubuntu.com/questions/964377/snap-application-doesnt-see-files-from-another-partition
https://askubuntu.com/questions/1033344/how-to-give-snaps-access-to-somedir

以上是解决该问题的两种可能方案。您可以根据您的具体情况选择适合您的解决方案。

正文完