Docker群约束通配符



我正在10个不同的主机/服务器/机器上运行Docker群,所有这些主机/服务器都有不同的标签,例如。nginx_1nginx_2nginx_3nginx_4app_1app_2app_3app_4测试_1测试_2

使用Docker群约束是否有一种方法可以使用标签和通配符指定服务可以在哪个节点上运行,该标签和通配符将使服务在任何标签以nginx开头的节点上运行。例如

--constraint 'node.labels.name ==nginx*' 

我们暂时不能在--constraint中使用通配符。

您可以用一个新标签标记所有nginx节点,例如:

docker node update --label-add type=web node1
docker node update --label-add type=web node2
...

并使用--constraint仅在web标记的节点上创建nginx服务:

docker service create 
--name nginx 
--constraint 'node.labels.type == web' 
nginx

最新更新