diff --git a/docs/reference/commandline/service_create.md b/docs/reference/commandline/service_create.md index c4abf42644..99d4e7ddc2 100644 --- a/docs/reference/commandline/service_create.md +++ b/docs/reference/commandline/service_create.md @@ -94,7 +94,7 @@ ID NAME REPLICAS IMAGE COMMAND ``` -### Create a service with a rolling update constraints +### Create a service with a rolling update policy ```bash @@ -133,7 +133,7 @@ $ docker service create \ For more information about labels, refer to [apply custom metadata](../../userguide/labels-custom-metadata.md) -### Service mode +### Set service mode Is this a replicated service or a global service. A replicated service runs as many tasks as specified, while a global service runs on each active node in the @@ -145,6 +145,33 @@ The following command creates a "global" service: $ docker service create --name redis_2 --mode global redis:3.0.6 ``` +### Specify service constraints + +You can limit the set of nodes where a task can be scheduled by defining +constraint expressions. Multiple constraints find nodes that satisfy every +expression (AND match). Constraints can match node or Docker Engine labels as +follows: + +| node attribute | matches | example | +|:------------- |:-------------| :---------------------------------------------| +| node.id | node ID | `node.id == 2ivku8v2gvtg4` | +| node.hostname | node hostname | `node.hostname != node-2` | +| node.role | node role: manager | `node.role == manager` | +| node.labels | user defined node labels | `node.labels.security == high` | +| engine.labels | Docker Engine's labels | `engine.labels.operatingsystem == ubuntu 14.04`| + +`engine.labels` apply to Docker Engine labels like operating system, +drivers, etc. Swarm administrators add `node.labels` for operational purposes by +using the `docker node update` command. + +For example, the following limits tasks for the redis service to nodes where the +node type label equals queue: + +```bash +$ docker service create \ + --name redis_2 \ + --constraint node.labels.type == queue +``` ## Related information