Skip to content

Commit 07d5bda

Browse files
authored
Enhance examples in reference/compose-file/configs
1 parent 5408a2e commit 07d5bda

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

content/reference/compose-file/configs.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ By default, the config:
1515
- Is owned by the user running the container command but can be overridden by service configuration.
1616
- Has world-readable permissions (mode 0444), unless the service is configured to override this.
1717

18-
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`.
18+
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`.
1919

2020
- `file`: The config is created with the contents of the file at the specified path.
2121
- `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:
4747

4848
## Example 2
4949

50+
External configs lookup can also use a distinct key by specifying a `name`.
51+
52+
The following
53+
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
54+
variables, but exposed to containers as hard-coded ID `http_config`.
55+
56+
```yml
57+
configs:
58+
http_config:
59+
external: true
60+
name: "${HTTP_CONFIG_KEY}"
61+
```
62+
63+
## Example 3
64+
5065
`<project_name>_app_config` is created when the application is deployed,
5166
by registering the inlined content as the configuration data. This means Compose infers variables when creating the config, which allows you to
5267
adjust content according to service configuration:
@@ -60,19 +75,15 @@ configs:
6075
spring.application.name=${COMPOSE_PROJECT_NAME}
6176
```
6277

63-
## Example 3
78+
## Example 4
6479

65-
External configs lookup can also use a distinct key by specifying a `name`.
66-
67-
The following
68-
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
69-
variables, but exposed to containers as hard-coded ID `http_config`.
80+
`<project_name>_simple_config` is created when the application is deployed,
81+
using the value of an environment variable as the configuration data. This is useful for simple configuration values that don’t require interpolation:
7082

7183
```yml
7284
configs:
73-
http_config:
74-
external: true
75-
name: "${HTTP_CONFIG_KEY}"
85+
simple_config:
86+
environment: "SIMPLE_CONFIG_VALUE"
7687
```
7788

7889
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.

0 commit comments

Comments
 (0)