Docker:安装来自其他 docker 服务的卷(不是容器)

Docker: mounting volumes from other docker service (not container)

我有两个主机,每个主机上 运行 docker 服务。

主机 A 的容器想要使用从主机 B 创建的卷。

这可能吗?

糟糕,这两个服务应该在同一台主机上,但您可以做一件事。

All reused data volumes are mounted on the same paths as in the source service. Containers must be on the same host in order to share volumes, so the containers of the new service will deploy to the same nodes where the source service containers are deployed.

https://docs.docker.com/docker-cloud/apps/volumes/

可能的解决方案:

  1. 将卷装载到主机目录
  2. 在您的节点之间同步该目录

你可以用NFS同步所有节点的目录,我自己用过很好用