环境准备
准备三台Linux机器,之间可以通过SSH相互通信。
hostname |
ip |
ssh username |
ssh password |
docker-host1 |
192.168.200.10 |
vagrant |
vagrant |
docker-host2 |
192.168.200.11 |
vagrant |
vagrant |
docker-host3 |
192.168.200.12 |
vagrant |
vagrant |
安装plugin
在其中两台机器上安装一个plugin vieux/sshfs
docker plugin install --grant-all-permissions vieux/sshfs
创建volume
docker volume create --driver vieux/sshfs \
-o sshcmd=vagrant@192.168.200.12:/home/vagrant \
-o password=vagrant \
sshvolume
查看
docker volume ls
docker volume inspect sshvolume
创建容器挂载Volume
docker run -it -v sshvolume:/app busybox sh
ls
cd /app
ls
echo "this is ssh volume"> test.txt
ls
more test.txt
这个文件我们可以在docker-host3上看到
pwd
ls
more test.txt