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