The scale command will take the service you pass the command and scale it to the number you define; for example, to add more worker containers I just need to run:
$ docker-compose scale worker=3
However, this actually gives the following warning:
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
What we should now be using is the following command:
$ docker-compose up -d --scale worker=3
While the scale command is in the current version of Docker Compose, it will be removed from future versions.
You will notice that I chose to scale the number of worker containers. There is a good reason for this as you will see for yourself if you try running the following command:
$ docker-compose up -d --scale vote=3
You will notice that while Docker Compose creates the additional two containers, they fail to start with the following error:
That is because we cannot have three individual containers all trying to map to the same port. There is a workaround for this and we will look at that in more detail in our next chapter.