Run hybrid workloads in Swarm

To run Windows workloads in a hybrid Windows Swarm cluster, you must target your workloads to nodes that are running the correct Windows version. Failure to correctly target your workloads may result in an operating system mismatch error.

  1. Verify that nodes running the appropriate Windows version are present in the cluster. Use an OsVersion label of 10.0.17763 for Windows Server 2019 and 10.0.20348 for Windows Server 2022. For example:

    docker node ls -f "node.label=OsVersion=10.0.20348"
    

    Example output:

    ID                            HOSTNAME                  STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION
    yft1t1mnytt524y03zmdevzuk     win2022-node-1            Ready     Active                          20.10.12
    
  2. Create a service that runs the required version of Windows Server, in this case Windows Server 2022. The service requires the inclusion of various constraints, to ensure that it is scheduled on the correct node. For example:

    docker service create --name windows2022-example-service \
    --constraint "node.platform.OS == windows" \
    --constraint "node.labels.OsVersion == 10.0.20348" \
    mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd "/c ping -t localhost"
    
  3. Verify that the service is scheduled on the required node:

    docker service ps windows2022-example-service
    

    Example output:

    ID             NAME                            IMAGE                                           NODE                      DESIRED STATE   CURRENT STATE           ERROR     PORTS
    uqrosib62602   windows2022-example-service.1   mcr.microsoft.com/windows/nanoserver:ltsc2022   win2022-node-1            Running         Running 9 minutes ago