mirror of
https://github.com/docker/cli.git
synced 2025-08-27 13:42:00 +03:00
* Added two new modes accepted by the `--mode` flag * `replicated-job` creates a replicated job * `global-job` creates a global job. * When using `replicated-job` mode, the `replicas` flag sets the `TotalCompletions` parameter of the job. This is the total number of tasks that will run * Added a new flag, `max-concurrent`, for use with `replicated-job` mode. This flag sets the `MaxConcurrent` parameter of the job, which is the maximum number of replicas the job will run simultaneously. * When using `replicated-job` or `global-job` mode, using any of the update parameter flags will result in an error, as jobs cannot be updated in the traditional sense. * Updated the `docker service ls` UI to include the completion status (completed vs total tasks) if the service is a job. * Updated the progress bars UI for service creation and update to support jobs. For jobs, there is displayed a bar covering the overall progress of the job (the number of tasks completed over the total number of tasks to complete). * Added documentation explaining the use of the new flags, and of jobs in general. Signed-off-by: Drew Erny <derny@mirantis.com>
105 lines
2.8 KiB
Markdown
105 lines
2.8 KiB
Markdown
---
|
|
title: "service scale"
|
|
description: "The service scale command description and usage"
|
|
keywords: "service, scale"
|
|
---
|
|
|
|
# service scale
|
|
|
|
```markdown
|
|
Usage: docker service scale [OPTIONS] SERVICE=REPLICAS [SERVICE=REPLICAS...]
|
|
|
|
Scale one or multiple replicated services
|
|
|
|
Options:
|
|
-d, --detach Exit immediately instead of waiting for the service to converge (default true)
|
|
--help Print usage
|
|
```
|
|
|
|
## Description
|
|
|
|
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
|
|
services which are global mode. The command will return immediately, but the
|
|
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.
|
|
|
|
> **Note**
|
|
>
|
|
> This is a cluster management command, and must be executed on a swarm
|
|
> manager node. To learn about managers and workers, refer to the
|
|
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
|
|
> documentation.
|
|
|
|
## Examples
|
|
|
|
### Scale a single service
|
|
|
|
The following command scales the "frontend" service to 50 tasks.
|
|
|
|
```bash
|
|
$ docker service scale frontend=50
|
|
|
|
frontend scaled to 50
|
|
```
|
|
|
|
The following command tries to scale a global service to 10 tasks and returns an error.
|
|
|
|
```bash
|
|
$ docker service create --mode global --name backend backend:latest
|
|
|
|
b4g08uwuairexjub6ome6usqh
|
|
|
|
$ docker service scale backend=10
|
|
|
|
backend: scale can only be used with replicated or replicated-job mode
|
|
```
|
|
|
|
Directly afterwards, run `docker service ls`, to see the actual number of
|
|
replicas.
|
|
|
|
```bash
|
|
$ docker service ls --filter name=frontend
|
|
|
|
ID NAME MODE REPLICAS IMAGE
|
|
3pr5mlvu3fh9 frontend replicated 15/50 nginx:alpine
|
|
```
|
|
|
|
You can also scale a service using the [`docker service update`](service_update.md)
|
|
command. The following commands are equivalent:
|
|
|
|
```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
|
|
|
|
ID NAME MODE REPLICAS IMAGE
|
|
3pr5mlvu3fh9 frontend replicated 5/5 nginx:alpine
|
|
74nzcxxjv6fq backend replicated 3/3 redis:3.0.6
|
|
```
|
|
|
|
## Related commands
|
|
|
|
* [service create](service_create.md)
|
|
* [service inspect](service_inspect.md)
|
|
* [service logs](service_logs.md)
|
|
* [service ls](service_ls.md)
|
|
* [service rm](service_rm.md)
|
|
* [service rollback](service_rollback.md)
|
|
* [service ps](service_ps.md)
|
|
* [service update](service_update.md)
|