Set the number of containers for a service to scale horizontally.
Currently, Docker Compose can only start one container in each service. To expand the number of containers, manually set the number after the container is started.
You can use the scale
label to scale as the container is started.
Moreover, after a container is deleted, you can redeploy the application by completing the following steps:
- Log on to the Container Service console.
- Click Applications in the left-side navigation pane.
- Click Redeploy at the right of the application you want to redeploy. Then, Container Service restarts the container or creates a new container to restore the number of containers to the specified quantity.
Example:
web:
image: wordpress:4.2
ports:
- 80
links:
- db:mysql
labels:
aliyun.scale: "3"
db:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=password