I have a stack file in which I am trying to tell it to use either of two hostnames I am providing. is this possible? The service does not start with these variables however, when removing at least one of them, it works. Thank you for your help!
stack file:
deploy:
placement:
constraints:
- node.hostname == myhost1
- node.hostname == myhost2
The placement constraints are AND chained.
Though, you could add node labels to both hosts and use the node label as placement constraint instead. I use the label "mycustomlabel=true" to illustrate the usage.
On a manager node:
docker node update --label-add mycustomlabel=true myhost1
docker node update --label-add mycustomlabel=true myhost2
Then use the node label as a placement constraint:
deploy:
placement:
constraints:
- node.labels.mycustomlabel == true
Of course the label can have a key=value of your choosing. A node can have multiple node labels.