edit-icon download-icon

Variable substitution

Last Updated: Feb 12, 2018

Container Service supports the parameterized Docker Compose template. The template can include the environment variables as parameters. When the template is deployed, you are prompted to enter the parameter values, and the template variables are substituted during the deployment.

For example, you can define the parameter POSTGRES_VERSION.

  1. db:
  2. image: "postgres:${POSTGRES_VERSION}"

When the preceding Compose template is deployed, Container Service prompts you to enter the value of the POSTGRES_VERSION parameter, such as 9.3. Container Service substitutes the variable of the Compose template with this parameter value. In this example, a postgres:9.3 container is deployed.

Container Service is fully compatible with Docker Compose syntax, and you can use either $VARIABLE or ${VARIABLE} syntax in the template.

In the Compose template, you can use $$ to escape strings containing $. In this way, Container Service will not erroneously treat such a string as the parameter.

For more information on the variable substitution supported in the Compose template, see Variable substitution.

Thank you! We've received your feedback.