docker - Docker 使用 sshfs 挂载远程卷
问题描述
我知道这个问题已经在网上完成,但我无法找到适合我的解决方案。
我安装了一台服务器 (VM1),sshfs
它应该提供远程文件系统存储。我有另一台运行容器的服务器 (VM2),我希望这些容器使用 VM1 中托管的卷。
我遵循了这个官方的 docker guide 所以在 VM1 我跑了:
docker plugin install vieux/sshfs DEBUG=1 sshkey.source=/home/debian/.ssh/
在 VM 2 中,我运行:
docker volume create --name remotevolume -d vieux/sshfs -o sshcmd=debian@vm1:/home/debian/sshfs300 -o IdentityFile=/home/csicari/data/Mega/lavoro/keys/vm-csicari.key -o -o allow_other -o nonempty
这是检查输出:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "vieux/sshfs:latest",
"Labels": {},
"Mountpoint": "/mnt/volumes/895d7f7679f69131500c786d7fe5fdc1",
"Name": "remotevolume",
"Options": {
"IdentityFile": "/home/csicari/data/Mega/lavoro/keys/vm-csicari.key",
"sshcmd": "debian@vm1:/home/debian/sshfs300"
},
"Scope": "local"
}
]
在 VM1 中,我还运行了:
docker run -it -v remotevolume:/home -d ubuntu
但我得到了这个错误:
docker: Error response from daemon: VolumeDriver.Mount: sshfs command execute failed: exit status 1 (read: Connection reset by peer
). See 'docker run --help'.
解决方案
也许这是一个很长的问题,也许它会帮助其他新手。远程 VM/etc/ssh/sshd_config
文件内容检查属性PasswordAuthentication yes
如果它是“是”,我们可以使用密码传递参数。否则,将其更改为“否”并重新启动 ssh 或 sshd 服务。
service ssh restart
service ssh status
还有密码验证。根据您的 PAM 配置,请同时检查。
如果是AWS实例使用命令passwd
ubuntu重置密码#这里ubuntu是ec2 ubuntu实例中的默认用户
推荐阅读
- r - 通过数据框中的数字有效地填充 NA 单元格
- java - 我无法将多张图片上传到服务器
- spring - JWT 身份验证导致与常规身份验证发生冲突。我无法从登录页面登录
- flutter - 我无法在图像小部件中显示从网络图像选择器获得的图像
- python - 如何获取类似 TreeView 的文件下拉列表
- google-drive-api - 如何使共享的 Colab 笔记本能够加载 h5 文件?
- reactjs - React 类组件不更新路由器上的状态
- javascript - 刷新同一页面而不重新加载?
- python - 如何使用 Python 将任何目录添加到 PATH?
- cors - 如何在 Vercel 中启用 cors