affinity:container!=容器服务名称(可以是正则)
举个例子:stack_ds.yaml
# cat stack_dsc.yaml version: '3.0' services: test: image: xxxxxxxxx logging: driver: "json-file" options: max-size: "50m" max-file: "10" environment: - MYSQL_HOST=192.168. - MYSQL_DATABASE=dsc - MYSQL_USERNAME=u_dsc - MYSQL_PORT=3306 - MYSQL_PASSWORD=xxxx - "affinity:container!=test" deploy: mode: replicated replicas: 3 restart_policy: condition: on-failure resources: limits: memory: 1048m networks: - basenet networks: basenet: external: true
"affinity:container!=test"
节点上若有test的容器,则不在该节点启动。
若节点小于3,则忽略上一条规则