⚡ NEW: Reference/cli/docker/service/scale - High Quality

docker service scale

DescriptionScale one or multiple replicated services
Usagedocker service scale SERVICE=REPLICAS [SERVICE=REPLICAS...]

Swarm This command works with the Swarm orchestrator.

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 in the documentation.

Options

OptionDefaultDescription
-d, --detachAPI 1.29+ Exit immediately instead of waiting for the service to converge

Examples

Scale a single service

The following command scales the "frontend" service to 50 tasks.

The following command tries to scale a global service to 10 tasks and returns an error.

Directly afterwards, run docker service ls, to see the actual number of replicas.

You can also scale a service using the docker service update command. The following commands are equivalent:

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: