将 SSHFS 卷挂载到 Docker 实例中

Ral*_*lph 17 ssh mount fuse sshfs docker

我使用 SSHFS 在我的主机上挂载一个远程文件系统,我希望能够从 Docker 容器内部访问它。

我挂载远程文件系统

sshfs -o idmap=user,uid=$(id -u),gid=$(id -g) user@remote:directory /path/to/sshfs

而且,使用 Docker,根据我的使用情况,我收到以下错误--mount

docker run  -it -v /path/to/sshfs:/target myimage bash
docker: Error response from daemon: error while creating mount source path '/path/to/sshfs': mkdir /path/to/sshfs: file exists.
Run Code Online (Sandbox Code Playgroud)

-v

docker run -it  --mount src=/path/to/sshfs,target=/target,type=bind  myimage bash
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /path/to/sshfs.
See 'docker run --help'
Run Code Online (Sandbox Code Playgroud)

是否可以将 sshfs 挂载点挂载到容器中?

Mic*_*ton 19

需要以下步骤:

  1. 取消注释user_allow_other/etc/fuse.conf

  2. 卸载 FUSE 文件系统

  3. 重新挂载 FUSE 文件系统sshfs -o allow_other user@....(确保包含该-o allow_other选项)

  4. 尝试再次启动容器

  • 谢谢!我按照你说的做了,然后安装了`sshfs -o allow_other`,它工作了! (4认同)