Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 22b4b51

Browse files
committed
docs: service create: document os/arch constraints and more examples
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit f26e9a3a61dc2f4e6b78627fb96ec31e3ccc914f) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 7fac7eb1af329c06c9a56d28354230130dd60f85 Component: cli
1 parent 09315bf commit 22b4b51

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

components/cli/docs/reference/commandline/service_create.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,15 @@ or _exclude_ (`!=`) rule. Multiple constraints find nodes that satisfy every
672672
expression (AND match). Constraints can match node or Docker Engine labels as
673673
follows:
674674

675-
node attribute | matches | example
676-
-------------------|--------------------------|-----------------------------------------------
677-
`node.id` | Node ID | `node.id==2ivku8v2gvtg4`
678-
`node.hostname` | Node hostname | `node.hostname!=node-2`
679-
`node.role` | Node role | `node.role==manager`
680-
`node.labels` | User-defined node labels | `node.labels.security==high`
681-
`engine.labels` | Docker Engine's labels | `engine.labels.operatingsystem==ubuntu-14.04`
675+
node attribute | matches | example
676+
---------------------|--------------------------------|-----------------------------------------------
677+
`node.id` | Node ID | `node.id==2ivku8v2gvtg4`
678+
`node.hostname` | Node hostname | `node.hostname!=node-2`
679+
`node.role` | Node role (`manager`/`worker`) | `node.role==manager`
680+
`node.platform.os` | Node operating system | `node.platform.os==windows`
681+
`node.platform.arch` | Node architecture | `node.platform.arch==x86_64`
682+
`node.labels` | User-defined node labels | `node.labels.security==high`
683+
`engine.labels` | Docker Engine's labels | `engine.labels.operatingsystem==ubuntu-14.04`
682684

683685

684686
`engine.labels` apply to Docker Engine labels like operating system, drivers,
@@ -691,10 +693,45 @@ node type label equals queue:
691693
```bash
692694
$ docker service create \
693695
--name redis_2 \
696+
--constraint node.platform.os==linux \
694697
--constraint node.labels.type==queue \
695698
redis:3.0.6
696699
```
697700

701+
If the service constraints exclude all nodes in the cluster, a message is printed
702+
that no suitable node is found, but the scheduler will start a reconciliation
703+
loop and deploy the service once a suitable node becomes available.
704+
705+
In the example below, no node satisfying the constraint was found, causing the
706+
service to not reconcile with the desired state:
707+
708+
```bash
709+
$ docker service create \
710+
--name web \
711+
--constraint node.labels.region==east \
712+
nginx:alpine
713+
714+
lx1wrhhpmbbu0wuk0ybws30bc
715+
overall progress: 0 out of 1 tasks
716+
1/1: no suitable node (scheduling constraints not satisfied on 5 nodes)
717+
718+
$ docker service ls
719+
ID NAME MODE REPLICAS IMAGE PORTS
720+
b6lww17hrr4e web replicated 0/1 nginx:alpine
721+
```
722+
723+
After adding the `region=east` label to a node in the cluster, the service
724+
reconciles, and the desired number of replicas are deployed:
725+
726+
```bash
727+
$ docker node update --label-add region=east yswe2dm4c5fdgtsrli1e8ya5l
728+
yswe2dm4c5fdgtsrli1e8ya5l
729+
730+
$ docker service ls
731+
ID NAME MODE REPLICAS IMAGE PORTS
732+
b6lww17hrr4e web replicated 1/1 nginx:alpine
733+
```
734+
698735
### Specify service placement preferences (--placement-pref)
699736

700737
You can set up the service to divide tasks evenly over different categories of

0 commit comments

Comments
 (0)