You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/reference/compose-file/configs.md
+21-10Lines changed: 21 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ By default, the config:
16
16
- Is owned by the user running the container command but can be overridden by service configuration.
17
17
- Has world-readable permissions (mode 0444), unless the service is configured to override this.
18
18
19
-
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`.
19
+
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`.
20
20
21
21
-`file`: The config is created with the contents of the file at the specified path.
22
22
-`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:
48
48
49
49
## Example 2
50
50
51
+
External configs lookup can also use a distinct key by specifying a `name`.
52
+
53
+
The following
54
+
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
55
+
variables, but exposed to containers as hard-coded ID `http_config`.
56
+
57
+
```yml
58
+
configs:
59
+
http_config:
60
+
external: true
61
+
name: "${HTTP_CONFIG_KEY}"
62
+
```
63
+
64
+
## Example 3
65
+
51
66
`<project_name>_app_config`is created when the application is deployed,
52
67
by registering the inlined content as the configuration data. This means Compose infers variables when creating the config, which allows you to
53
68
adjust content according to service configuration:
@@ -61,19 +76,15 @@ configs:
61
76
spring.application.name=${COMPOSE_PROJECT_NAME}
62
77
```
63
78
64
-
## Example 3
79
+
## Example 4
65
80
66
-
External configs lookup can also use a distinct key by specifying a `name`.
67
-
68
-
The following
69
-
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
70
-
variables, but exposed to containers as hard-coded ID `http_config`.
81
+
`<project_name>_simple_config`is created when the application is deployed,
82
+
using the value of an environment variable as the configuration data. This is useful for simple configuration values that don’t require interpolation:
71
83
72
84
```yml
73
85
configs:
74
-
http_config:
75
-
external: true
76
-
name: "${HTTP_CONFIG_KEY}"
86
+
simple_config:
87
+
environment: "SIMPLE_CONFIG_VALUE"
77
88
```
78
89
79
90
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