August 2017
Intermediate to advanced
332 pages
9h 16m
English
Docker Compose provides the functionality to automatically create multiple instances of the same container. We can either specify the replicas: <number> parameter inside docker-compose.yml or use the docker-compose scale command.
As an example, let's run the environment again and replicate the calculator container:
$ docker-compose up -d$ docker-compose scale calculator=5
We can check which containers are running:
$ docker-compose ps Name Command State Ports ---------------------------------------------------------------------------calculator_calculator_1 java -jar app.jar Up 0.0.0.0:32777->8080/tcpcalculator_calculator_2 java -jar app.jar Up 0.0.0.0:32778->8080/tcpcalculator_calculator_3 java -jar app.jar Up 0.0.0.0:32779->8080/tcp ...
Read now
Unlock full access