diff --git a/content/reference/compose-file/configs.md b/content/reference/compose-file/configs.md index 99a22479e9a..052831aa922 100644 --- a/content/reference/compose-file/configs.md +++ b/content/reference/compose-file/configs.md @@ -15,7 +15,7 @@ By default, the config: - Is owned by the user running the container command but can be overridden by service configuration. - Has world-readable permissions (mode 0444), unless the service is configured to override this. -The top-level `configs` declaration defines or references configuration data that is granted to services in your Compose application. The source of the config is either `file` or `external`. +The top-level `configs` declaration defines or references configuration data that is granted to services in your Compose application. The source of the config is either `file`, `environment`, `content`, or `external`. - `file`: The config is created with the contents of the file at the specified path. - `environment`: The config content is created with the value of an environment variable. Introduced in Docker Compose version [2.23.1](/manuals/compose/releases/release-notes.md#2231). @@ -47,6 +47,21 @@ configs: ## Example 2 +External configs lookup can also use a distinct key by specifying a `name`. + +The following +example modifies the previous one to look up a config using the parameter `HTTP_CONFIG_KEY`. The actual lookup key is set at deployment time by the [interpolation](interpolation.md) of +variables, but exposed to containers as hard-coded ID `http_config`. + +```yml +configs: + http_config: + external: true + name: "${HTTP_CONFIG_KEY}" +``` + +## Example 3 + `_app_config` is created when the application is deployed, by registering the inlined content as the configuration data. This means Compose infers variables when creating the config, which allows you to adjust content according to service configuration: @@ -60,19 +75,15 @@ configs: spring.application.name=${COMPOSE_PROJECT_NAME} ``` -## Example 3 +## Example 4 -External configs lookup can also use a distinct key by specifying a `name`. - -The following -example modifies the previous one to look up a config using the parameter `HTTP_CONFIG_KEY`. The actual lookup key is set at deployment time by the [interpolation](interpolation.md) of -variables, but exposed to containers as hard-coded ID `http_config`. +`_simple_config` is created when the application is deployed, +using the value of an environment variable as the configuration data. This is useful for simple configuration values that don’t require interpolation: ```yml configs: - http_config: - external: true - name: "${HTTP_CONFIG_KEY}" + simple_config: + environment: "SIMPLE_CONFIG_VALUE" ``` If `external` is set to `true`, all other attributes apart from `name` are irrelevant. If Compose detects any other attribute, it rejects the Compose file as invalid.