All Products
Document Center

Specified node scheduling

Last Updated: Feb 11, 2018

To deploy a service to a specified node, you can use the constraint keyword.

Note: The deployment constraint only works for newly created containers. It does not work when existing containers change the configurations.

In the following example, the service is deployed to node1.

  1. web:
  2. image: 'nginx:latest'
  3. restart: always
  4. environment:
  5. - 'constraint:aliyun.node_index==1'
  6. ports:
  7. - 80
  8. labels:
  9. aliyun.scale: 2

Container Service supports the following expressions:

constraint:aliyun.node_index==1Deploy the service to node1.
constraint:aliyun.node_index!=1 Do not deploy the service to node1.
constraint:aliyun.node_index==(1|2|3)Deploy the service to node1, node2, or node3.
constraint:aliyun.node_index!=(1|2|3)Deploy the service to a machine other than node1, node2, and node3.
affinity:image==~redisTry to deploy the service to a machine with a Redis image. The image full name is supported. For example,
affinity:service!=~redisTry not to deploy the service to a machine with a Redis service. For more information, see Service deployment constraints (affinity:service).