2016-10-14 18:30:36 -04:00
|
|
|
|
---
|
|
|
|
|
title: "service scale"
|
|
|
|
|
description: "The service scale command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
|
keywords: "service, scale"
|
2016-10-14 18:30:36 -04:00
|
|
|
|
---
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
|
<!-- This file is maintained within the docker/docker Github
|
|
|
|
|
repository at https://github.com/docker/docker/. Make all
|
|
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
|
will be rejected.
|
|
|
|
|
-->
|
|
|
|
|
|
2016-06-17 19:51:17 -04:00
|
|
|
|
# service scale
|
|
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
|
```markdown
|
|
|
|
|
Usage: docker service scale SERVICE=REPLICAS [SERVICE=REPLICAS...]
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
2016-11-02 03:53:18 -04:00
|
|
|
|
Scale one or multiple replicated services
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
|
Options:
|
|
|
|
|
--help Print usage
|
|
|
|
|
```
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
### Scale a service
|
|
|
|
|
|
2016-11-03 14:20:53 -04:00
|
|
|
|
The scale command enables you to scale one or more replicated services either up
|
|
|
|
|
or down to the desired number of replicas. This command cannot be applied on
|
2016-11-02 03:53:18 -04:00
|
|
|
|
services which are global mode. The command will return immediately, but the
|
2016-10-19 13:25:45 -04:00
|
|
|
|
actual scaling of the service may take some time. To stop all replicas of a
|
|
|
|
|
service while keeping the service active in the swarm you can set the scale to 0.
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
|
|
For example, the following command scales the "frontend" service to 50 tasks.
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ docker service scale frontend=50
|
|
|
|
|
frontend scaled to 50
|
|
|
|
|
```
|
|
|
|
|
|
2016-11-02 03:53:18 -04:00
|
|
|
|
The following command tries to scale a global service to 10 tasks and returns an error.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ docker service create --mode global --name backend backend:latest
|
|
|
|
|
b4g08uwuairexjub6ome6usqh
|
|
|
|
|
$ docker service scale backend=10
|
|
|
|
|
backend: scale can only be used with replicated mode
|
|
|
|
|
```
|
|
|
|
|
|
2016-06-17 19:51:17 -04:00
|
|
|
|
Directly afterwards, run `docker service ls`, to see the actual number of
|
2016-10-19 13:25:45 -04:00
|
|
|
|
replicas.
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ docker service ls --filter name=frontend
|
|
|
|
|
|
2016-11-03 14:20:53 -04:00
|
|
|
|
ID NAME REPLICAS IMAGE
|
2016-06-17 19:51:17 -04:00
|
|
|
|
3pr5mlvu3fh9 frontend 15/50 nginx:alpine
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
You can also scale a service using the [`docker service update`](service_update.md)
|
2016-10-19 13:25:45 -04:00
|
|
|
|
command. The following commands are equivalent:
|
2016-06-17 19:51:17 -04:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ docker service scale frontend=50
|
|
|
|
|
$ docker service update --replicas=50 frontend
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Scale multiple services
|
|
|
|
|
|
|
|
|
|
The `docker service scale` command allows you to set the desired number of
|
|
|
|
|
tasks for multiple services at once. The following example scales both the
|
|
|
|
|
backend and frontend services:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ docker service scale backend=3 frontend=5
|
|
|
|
|
backend scaled to 3
|
|
|
|
|
frontend scaled to 5
|
|
|
|
|
|
|
|
|
|
$ docker service ls
|
2016-11-03 14:20:53 -04:00
|
|
|
|
ID NAME REPLICAS IMAGE
|
2016-06-17 19:51:17 -04:00
|
|
|
|
3pr5mlvu3fh9 frontend 5/5 nginx:alpine
|
|
|
|
|
74nzcxxjv6fq backend 3/3 redis:3.0.6
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Related information
|
|
|
|
|
|
|
|
|
|
* [service create](service_create.md)
|
|
|
|
|
* [service inspect](service_inspect.md)
|
|
|
|
|
* [service ls](service_ls.md)
|
|
|
|
|
* [service rm](service_rm.md)
|
2016-07-19 17:01:31 -04:00
|
|
|
|
* [service ps](service_ps.md)
|
2016-06-17 19:51:17 -04:00
|
|
|
|
* [service update](service_update.md)
|