...
1# service scale
2
3<!---MARKER_GEN_START-->
4Scale one or multiple replicated services
5
6### Options
7
8| Name | Type | Default | Description |
9|:-----------------|:-----|:--------|:----------------------------------------------------------------|
10| `-d`, `--detach` | | | Exit immediately instead of waiting for the service to converge |
11
12
13<!---MARKER_GEN_END-->
14
15## Description
16
17The scale command enables you to scale one or more replicated services either up
18or down to the desired number of replicas. This command cannot be applied on
19services which are global mode. The command will return immediately, but the
20actual scaling of the service may take some time. To stop all replicas of a
21service while keeping the service active in the swarm you can set the scale to 0.
22
23> **Note**
24>
25> This is a cluster management command, and must be executed on a swarm
26> manager node. To learn about managers and workers, refer to the
27> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
28> documentation.
29
30## Examples
31
32### Scale a single service
33
34The following command scales the "frontend" service to 50 tasks.
35
36```console
37$ docker service scale frontend=50
38
39frontend scaled to 50
40```
41
42The following command tries to scale a global service to 10 tasks and returns an error.
43
44```console
45$ docker service create --mode global --name backend backend:latest
46
47b4g08uwuairexjub6ome6usqh
48
49$ docker service scale backend=10
50
51backend: scale can only be used with replicated or replicated-job mode
52```
53
54Directly afterwards, run `docker service ls`, to see the actual number of
55replicas.
56
57```console
58$ docker service ls --filter name=frontend
59
60ID NAME MODE REPLICAS IMAGE
613pr5mlvu3fh9 frontend replicated 15/50 nginx:alpine
62```
63
64You can also scale a service using the [`docker service update`](service_update.md)
65command. The following commands are equivalent:
66
67```console
68$ docker service scale frontend=50
69$ docker service update --replicas=50 frontend
70```
71
72### Scale multiple services
73
74The `docker service scale` command allows you to set the desired number of
75tasks for multiple services at once. The following example scales both the
76backend and frontend services:
77
78```console
79$ docker service scale backend=3 frontend=5
80
81backend scaled to 3
82frontend scaled to 5
83
84$ docker service ls
85
86ID NAME MODE REPLICAS IMAGE
873pr5mlvu3fh9 frontend replicated 5/5 nginx:alpine
8874nzcxxjv6fq backend replicated 3/3 redis:3.0.6
89```
90
91## Related commands
92
93* [service create](service_create.md)
94* [service inspect](service_inspect.md)
95* [service logs](service_logs.md)
96* [service ls](service_ls.md)
97* [service rm](service_rm.md)
98* [service rollback](service_rollback.md)
99* [service ps](service_ps.md)
100* [service update](service_update.md)
View as plain text