mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
Enhance examples in reference/compose-file/configs (#23185)
## Description Reworked docker-compose configs examples slightly
This commit is contained in:
@@ -16,7 +16,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).
|
||||
@@ -48,6 +48,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
|
||||
|
||||
`<project_name>_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:
|
||||
@@ -61,19 +76,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`.
|
||||
`<project_name>_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.
|
||||
|
||||
Reference in New Issue
Block a user