Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker swarm compose placement constraints boolean or condition

Is it possible to specify a boolean or condition in the placement constraints of docker composes? I'm looking for something that can emulate this syntax:

services:
  service1:
    deploy:
      placement:
        constraints:
          - <condition1> || <condition2>
like image 950
Meidan Alon Avatar asked Oct 19 '25 07:10

Meidan Alon


2 Answers

I've looked for this, but after 1 year and 6 months, Swarm still doesn't support the 'or operation'.

Therefore, the current equivalent operation is to group all other labels except the condition into 'not equal' operations.

if you want label == (1 | 2) then..

constraints:
  - label != 3
  - label != 4
  ... 
  - label != n

This looks bad but is currently the only possible way in swarm.

like image 166
Code Dirty Avatar answered Oct 21 '25 22:10

Code Dirty


No it is not possible. You can't do what you want.

like image 26
Ryabchenko Alexander Avatar answered Oct 21 '25 23:10

Ryabchenko Alexander



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!