【发布时间】:2018-05-08 18:51:43
【问题描述】:
我正在尝试使用 NFS 卷在两个容器之间共享数据。
我在我的 [server/docker manager] var/nfsshare 中设置了一个 nfs 共享驱动器,我的 [client/docker worker] /mnt/nfs/var/nfsshare 也可以使用这个相同的驱动器,并且我能够共享数据。
采取的步骤 将此位置用作我的 docker compose 文件中的卷。 当我使用 docker-compose up 来启动我的容器时,一切正常,我可以共享数据。 但是当我启动 docker swarm 时,我的 [client/worker] 机器中的容器无法访问挂载的卷。
这是我的撰写文件
version: '3.5'
services:
workerA:
image: custom1
tty: true
deploy:
replicas: 2
placement:
constraints: [node.role == worker]
volumes:
- type: volume
source : test
target : /data
volume:
nocopy: true
serverB:
image: custom2
tty: true
deploy:
placement:
constraints: [node.role == manager]
ports:
- "7000:7000"
volumes:
- type: volume
source : test
target : /data
volume:
nocopy: true
volumes:
test
driver: local
driver_opts:
type: "nfs"
o: addr=192.168.0.100,nolock,soft,rw # this is the IP of the host for the manager.
device: ":/var/nfsshare"
我在这里缺少什么?
【问题讨论】:
标签: docker docker-compose docker-swarm nfs