yaml文件

version: "3.8"
services:
  GPU:
    image: python:3.8
    deploy:
        mode: global
        placement:
          constraints: [node.labels.isgpu == true ]

给节点打上标签

docker node update --label-add isgpu=false node1
docker node update --label-add isgpu=true node2

#查看标签