mirror of https://github.com/docker/docs.git
add constraint to service create ref
Signed-off-by: Charles Smith <charles.smith@docker.com> (cherry picked from commit 093817031acd2b8dc17cba5c3c994b2d6d19dc0e) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
7a09cd2772
commit
e90025aa76
|
|
@ -96,7 +96,7 @@ ID NAME REPLICAS IMAGE COMMAND
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Create a service with a rolling update constraints
|
### Create a service with a rolling update policy
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -135,7 +135,7 @@ $ docker service create \
|
||||||
For more information about labels, refer to [apply custom
|
For more information about labels, refer to [apply custom
|
||||||
metadata](../../userguide/labels-custom-metadata.md)
|
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
|
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
|
many tasks as specified, while a global service runs on each active node in the
|
||||||
|
|
@ -147,6 +147,33 @@ The following command creates a "global" service:
|
||||||
$ docker service create --name redis_2 --mode global redis:3.0.6
|
$ 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
|
## Related information
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue