我想将堆栈部署到 Docker 群,我希望每个节点都运行给定的服务。
我查看了 deploy.placement
配置,我发现的最接近的选项是放置首选项 spread=node.label.abc
,它将在匹配的节点上平均分配服务标签。然而,这需要始终更新副本计数以匹配节点数量。
有没有一种方法可以在所有节点上自动部署服务,而无需手动更新副本计数?
最佳答案
Is there a way to automatically deploy a service on all the nodes without manually updating the replica count?
是的,将您的服务部署在 global mode而不是复制。链接中的示例:
version: '3'
services:
worker:
image: dockersamples/examplevotingapp_worker
deploy:
mode: global
这将在符合您的约束的每个节点上运行容器的单个实例。
关于Docker swarm - 如何在 swarm 中的每个节点上复制服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49956626/