Docker - Scale (Number of container for a service)

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

Scale sets the number of containers to run for a service.

2 - Management

2.1 - Command line

# Use the up command with the --scale flag instead. - Scale SERVICE to NUM instances.
# docker-compose up --scale SERVICE=NUM        
docker-compose up --scale web=2 worker=3
# deprecated
docker-compose scale web=2 worker=3

It will overrides the scale setting in the Compose file if present.

Advertising

2.2 - docker-compose.yml

Added in version 2.2 file format. Version 2

web:
  image: busybox:latest
  command: echo 'scaled'
  scale: 3

3 - Documentation / Reference