edit-icon download-icon

Overview

Last Updated: Feb 12, 2018

Container Service supports describing multi-container applications by using the Docker Compose orchestration template.

The orchestration template allows you to describe an integrated application. The application can be composed of several services. For example, a portal application is composed of an Nginx service, a Web service, and a database service.

A service might have several containers. Make sure all of the containers have the same configurations. For example, the Web service in the preceding application can start two or more containers based on the traffic.

Capability

Container Service supports automatically deploying and managing a container application by using the orchestration template.

Swarm mode clusters support Compose V1/V2 and Compose V3 orchestration templates. For more information, see Compose V1, Compose V2, and Compose V3.

Container Service, based on the description in the Compose template of community version, provides extensions to simplify the deployment, operation, and maintenance of Web and microservice applications. For more information, see Label overview.

Example

The following is a WordPress application. It includes the Web service provided by WordPress image and the db service provided by MySQL image.

Compose V1/V2 template example

  1. web:
  2. image: wordpress:4.2
  3. ports:
  4. - "80"
  5. environment:
  6. - WORDPRESS_AUTH_KEY=changeme
  7. - WORDPRESS_SECURE_AUTH_KEY=changeme
  8. - WORDPRESS_LOGGED_IN_KEY=changeme
  9. - WORDPRESS_NONCE_KEY=changeme
  10. - WORDPRESS_AUTH_SALT=changeme
  11. - WORDPRESS_SECURE_AUTH_SALT=changeme
  12. - WORDPRESS_LOGGED_IN_SALT=changeme
  13. - WORDPRESS_NONCE_SALT=changeme
  14. restart: always
  15. links:
  16. - db:mysql
  17. labels:
  18. aliyun.log_store_wordpress: stdout
  19. aliyun.probe.url: http://container/license.txt
  20. aliyun.probe.initial_delay_seconds: "10"
  21. aliyun.routing.port_80: wordpress;http://www.example.com;https://www.nice.com
  22. aliyun.scale: "3"
  23. db:
  24. image: mysql:5.6
  25. environment:
  26. MYSQL_ROOT_PASSWORD: password
  27. restart: always
  28. labels:
  29. aliyun.log_store_mysql: stdout

Compose V3 template example

  1. version: '3'
  2. services:
  3. web:
  4. image: wordpress:4
  5. environment:
  6. - WORDPRESS_DB_PASSWORD=password
  7. - WORDPRESS_AUTH_KEY=changeme
  8. - WORDPRESS_SECURE_AUTH_KEY=changeme
  9. - WORDPRESS_LOGGED_IN_KEY=changeme
  10. - WORDPRESS_NONCE_KEY=changeme
  11. - WORDPRESS_AUTH_SALT=changeme
  12. - WORDPRESS_SECURE_AUTH_SALT=changeme
  13. - WORDPRESS_LOGGED_IN_SALT=changeme
  14. - WORDPRESS_NONCE_SALT=changeme
  15. - WORDPRESS_NONCE_AA=changeme
  16. ports:
  17. - 80
  18. depends_on:
  19. - mysql
  20. deploy:
  21. replicas: 3
  22. restart_policy:
  23. condition: on-failure
  24. labels:
  25. aliyun.routing.port_80: wordpress
  26. mysql:
  27. image: mysql:5.7
  28. environment:
  29. - MYSQL_ROOT_PASSWORD=password
  30. deploy:
  31. restart_policy:
  32. condition: on-failure
Thank you! We've received your feedback.