edit-icon download-icon


Last Updated: Nov 14, 2017

Set the access domain name of a service.


  1. aliyun.routing.port_$container_port: [http://]$domain|$domain_prefix[:$context_path]


  • $container_port: The container port.

    Note: This is not the host port.

  • $domain: The domain name. Enter your own domain name.
  • $domain_prefix: The domain name prefix. If you enter the domain name prefix, Container Service provides you with a domain name for test and the domain name suffix is .<cluster_id>.<region_id>.alicontainer.com.
  • $context_path: The request service path. You can select and distinguish different services according to the request path.

Domain name selection:

  • If HTTP protocol is used to expose the service, you can use the internal domain name (the top-level domain is alicontainer.com) provided by Container Service for test, or use your own domain name.
  • If HTTPS protocol is used, you can only use your own domain name. For example, www.example.com. Modify the DNS settings to specify the domain name to the Server Load Balancer service provided by the container cluster.

Format requirements of the label statement:

  • Container Service allocates subdomain names for each cluster, and you only need to provide the domain name prefix to bind the internal domain name. The domain name prefix only indicates a domain name level and cannot be separated with periods (.).
  • If you do not specify scheme, the HTTP protocol is used by default.
  • The length of the domain name cannot exceed 128 characters.
  • The length of the context root cannot exceed 128 characters.
  • When you bind several domain names to the service, use semicolons (;) to separate them.
  • A backend service can have several ports. Here, the port refers to the port exposed by the container. A port can only use one label for statement and a service with several ports need to state several labels.


Use the routing label.

Bind the internal domain name wordpress.<cluster_id>.<region_id>.alicontainer.com provided by Container Service and your own domain name http://wp.sample.com/context to port 80 of the Web service.

  1. web:
  2. image: wordpress:4.2
  3. links:
  4. - db:mysql
  5. labels:
  6. aliyun.routing.port_80: wordpress;http://wp.sample.com/context
  7. db:
  8. image: mysql
  9. environment:
  10. - MYSQL_ROOT_PASSWORD=password

The internal domain name you finally get is wordpress.cd3dfe269056e4543acbec5e19b01c074.cn-beijing.alicontainer.com.

After starting the Web service, you can access corresponding Web services by using the URL http://wordpress.cd3dfe269056e4543acbec5e19b01c074.cn-beijing.alicontainer.com or http://wp.sample.com/context.

To support HTTPS service, upload the HTTPS certificate by using the Server Load Balancer console on the Alibaba Cloud website. Then, bind the corresponding cluster to access the Server Load Balancer terminal.


Set whether or not routing keeps session sticky (namely, session persistence) during the routing request. With session persistence, during the session, the request is routed to the same backend container instead of being randomly routed to different containers for each request.

Note: The setting only works after aliyun.routing.port_$container_port is set.

The setting method is as follows:

  • Enable session persistence

aliyun.routing.session_sticky: true

  • Disable session persistence

aliyun.routing.session_sticky: false


  1. web:
  2. image: wordpress:4.2
  3. links:
  4. - db:mysql
  5. labels:
  6. aliyun.routing.port_80: wordpress;http://wp.sample.com/context
  7. aliyun.routing.session_sticky: true
  8. db:
  9. image: mysql
  10. environment:
  11. - MYSQL_ROOT_PASSWORD=password
Thank you! We've received your feedback.