...
1# update
2
3<!---MARKER_GEN_START-->
4Update a node
5
6### Options
7
8| Name | Type | Default | Description |
9|:----------------------------|:---------|:--------|:------------------------------------------------------|
10| `--availability` | `string` | | Availability of the node (`active`, `pause`, `drain`) |
11| [`--label-add`](#label-add) | `list` | | Add or update a node label (`key=value`) |
12| `--label-rm` | `list` | | Remove a node label if exists |
13| `--role` | `string` | | Role of the node (`worker`, `manager`) |
14
15
16<!---MARKER_GEN_END-->
17
18## Description
19
20Update metadata about a node, such as its availability, labels, or roles.
21
22> **Note**
23>
24> This is a cluster management command, and must be executed on a swarm
25> manager node. To learn about managers and workers, refer to the
26> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
27> documentation.
28
29## Examples
30
31### <a name="label-add"></a> Add label metadata to a node (--label-add)
32
33Add metadata to a swarm node using node labels. You can specify a node label as
34a key with an empty value:
35
36``` bash
37$ docker node update --label-add foo worker1
38```
39
40To add multiple labels to a node, pass the `--label-add` flag for each label:
41
42```console
43$ docker node update --label-add foo --label-add bar worker1
44```
45
46When you [create a service](service_create.md),
47you can use node labels as a constraint. A constraint limits the nodes where the
48scheduler deploys tasks for a service.
49
50For example, to add a `type` label to identify nodes where the scheduler should
51deploy message queue service tasks:
52
53``` bash
54$ docker node update --label-add type=queue worker1
55```
56
57The labels you set for nodes using `docker node update` apply only to the node
58entity within the swarm. Do not confuse them with the docker daemon labels for
59[dockerd](https://docs.docker.com/reference/cli/dockerd/).
60
61For more information about labels, refer to [apply custom
62metadata](https://docs.docker.com/engine/userguide/labels-custom-metadata/).
63
64## Related commands
65
66* [node demote](node_demote.md)
67* [node inspect](node_inspect.md)
68* [node ls](node_ls.md)
69* [node promote](node_promote.md)
70* [node ps](node_ps.md)
71* [node rm](node_rm.md)
View as plain text