github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/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/docker Github
     8       repository at https://github.com/docker/docker/. 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 SERVICE=REPLICAS [SERVICE=REPLICAS...]
    20  
    21  Scale one or multiple replicated services
    22  
    23  Options:
    24        --help   Print usage
    25  ```
    26  
    27  ## Description
    28  
    29  The scale command enables you to scale one or more replicated services either up
    30  or down to the desired number of replicas. This command cannot be applied on
    31  services which are global mode. The command will return immediately, but the
    32  actual scaling of the service may take some time. To stop all replicas of a
    33  service while keeping the service active in the swarm you can set the scale to 0.
    34  
    35  ## Examples
    36  
    37  ### Scale a single service
    38  
    39  The following command scales the "frontend" service to 50 tasks.
    40  
    41  ```bash
    42  $ docker service scale frontend=50
    43  
    44  frontend scaled to 50
    45  ```
    46  
    47  The following command tries to scale a global service to 10 tasks and returns an error.
    48  
    49  ```bash
    50  $ docker service create --mode global --name backend backend:latest
    51  
    52  b4g08uwuairexjub6ome6usqh
    53  
    54  $ docker service scale backend=10
    55  
    56  backend: scale can only be used with replicated mode
    57  ```
    58  
    59  Directly afterwards, run `docker service ls`, to see the actual number of
    60  replicas.
    61  
    62  ```bash
    63  $ docker service ls --filter name=frontend
    64  
    65  ID            NAME      MODE        REPLICAS  IMAGE
    66  3pr5mlvu3fh9  frontend  replicated  15/50     nginx:alpine
    67  ```
    68  
    69  You can also scale a service using the [`docker service update`](service_update.md)
    70  command. The following commands are equivalent:
    71  
    72  ```bash
    73  $ docker service scale frontend=50
    74  $ docker service update --replicas=50 frontend
    75  ```
    76  
    77  ### Scale multiple services
    78  
    79  The `docker service scale` command allows you to set the desired number of
    80  tasks for multiple services at once. The following example scales both the
    81  backend and frontend services:
    82  
    83  ```bash
    84  $ docker service scale backend=3 frontend=5
    85  
    86  backend scaled to 3
    87  frontend scaled to 5
    88  
    89  $ docker service ls
    90  
    91  ID            NAME      MODE        REPLICAS  IMAGE
    92  3pr5mlvu3fh9  frontend  replicated  5/5       nginx:alpine
    93  74nzcxxjv6fq  backend   replicated  3/3       redis:3.0.6
    94  ```
    95  
    96  ## Related commands
    97  
    98  * [service create](service_create.md)
    99  * [service inspect](service_inspect.md)
   100  * [service logs](service_logs.md)
   101  * [service ls](service_ls.md)
   102  * [service rm](service_rm.md)
   103  * [service ps](service_ps.md)
   104  * [service update](service_update.md)