github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/service_scale.md (about) 1 # service scale 2 3 <!---MARKER_GEN_START--> 4 Scale 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 17 The scale command enables you to scale one or more replicated services either up 18 or down to the desired number of replicas. This command cannot be applied on 19 services which are global mode. The command will return immediately, but the 20 actual scaling of the service may take some time. To stop all replicas of a 21 service 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 34 The following command scales the "frontend" service to 50 tasks. 35 36 ```console 37 $ docker service scale frontend=50 38 39 frontend scaled to 50 40 ``` 41 42 The 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 47 b4g08uwuairexjub6ome6usqh 48 49 $ docker service scale backend=10 50 51 backend: scale can only be used with replicated or replicated-job mode 52 ``` 53 54 Directly afterwards, run `docker service ls`, to see the actual number of 55 replicas. 56 57 ```console 58 $ docker service ls --filter name=frontend 59 60 ID NAME MODE REPLICAS IMAGE 61 3pr5mlvu3fh9 frontend replicated 15/50 nginx:alpine 62 ``` 63 64 You can also scale a service using the [`docker service update`](service_update.md) 65 command. 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 74 The `docker service scale` command allows you to set the desired number of 75 tasks for multiple services at once. The following example scales both the 76 backend and frontend services: 77 78 ```console 79 $ docker service scale backend=3 frontend=5 80 81 backend scaled to 3 82 frontend scaled to 5 83 84 $ docker service ls 85 86 ID NAME MODE REPLICAS IMAGE 87 3pr5mlvu3fh9 frontend replicated 5/5 nginx:alpine 88 74nzcxxjv6fq 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)