github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/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 <!-- This file is maintained within the docker/cli GitHub 8 repository at https://github.com/docker/cli/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # service scale 17 18 ```markdown 19 Usage: docker service scale [OPTIONS] SERVICE=REPLICAS [SERVICE=REPLICAS...] 20 21 Scale one or multiple replicated services 22 23 Options: 24 -d, --detach Exit immediately instead of waiting for the service to converge (default true) 25 --help Print usage 26 ``` 27 28 ## Description 29 30 The scale command enables you to scale one or more replicated services either up 31 or down to the desired number of replicas. This command cannot be applied on 32 services which are global mode. The command will return immediately, but the 33 actual scaling of the service may take some time. To stop all replicas of a 34 service while keeping the service active in the swarm you can set the scale to 0. 35 36 ## Examples 37 38 ### Scale a single service 39 40 The following command scales the "frontend" service to 50 tasks. 41 42 ```bash 43 $ docker service scale frontend=50 44 45 frontend scaled to 50 46 ``` 47 48 The following command tries to scale a global service to 10 tasks and returns an error. 49 50 ```bash 51 $ docker service create --mode global --name backend backend:latest 52 53 b4g08uwuairexjub6ome6usqh 54 55 $ docker service scale backend=10 56 57 backend: scale can only be used with replicated mode 58 ``` 59 60 Directly afterwards, run `docker service ls`, to see the actual number of 61 replicas. 62 63 ```bash 64 $ docker service ls --filter name=frontend 65 66 ID NAME MODE REPLICAS IMAGE 67 3pr5mlvu3fh9 frontend replicated 15/50 nginx:alpine 68 ``` 69 70 You can also scale a service using the [`docker service update`](service_update.md) 71 command. The following commands are equivalent: 72 73 ```bash 74 $ docker service scale frontend=50 75 $ docker service update --replicas=50 frontend 76 ``` 77 78 ### Scale multiple services 79 80 The `docker service scale` command allows you to set the desired number of 81 tasks for multiple services at once. The following example scales both the 82 backend and frontend services: 83 84 ```bash 85 $ docker service scale backend=3 frontend=5 86 87 backend scaled to 3 88 frontend scaled to 5 89 90 $ docker service ls 91 92 ID NAME MODE REPLICAS IMAGE 93 3pr5mlvu3fh9 frontend replicated 5/5 nginx:alpine 94 74nzcxxjv6fq backend replicated 3/3 redis:3.0.6 95 ``` 96 97 ## Related commands 98 99 * [service create](service_create.md) 100 * [service inspect](service_inspect.md) 101 * [service logs](service_logs.md) 102 * [service ls](service_ls.md) 103 * [service rm](service_rm.md) 104 * [service rollback](service_rollback.md) 105 * [service ps](service_ps.md) 106 * [service update](service_update.md)