Skip to content

Commit aa68ba2

Browse files
aevesdockerdvdksn
andauthored
ENGDOCS-2320 (#21463)
<!--Delete sections as needed --> ## Description A few new Compose Spec additions https://docker.atlassian.net/browse/ENGDOCS-2320 ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review --------- Co-authored-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 0de58f3 commit aa68ba2

File tree

3 files changed

+49
-12
lines changed

3 files changed

+49
-12
lines changed

content/manuals/compose/how-tos/environment-variables/set-environment-variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ The paths to your `.env` file, specified in the `env_file` attribute, are relati
9393
- path: ./override.env
9494
required: false
9595
```
96+
- As of Docker Compose version 2.30.0, you can use an alternative file format for the `env_file` with the `format` attribute. For more information, see [`format`](/reference/compose-file/services.md#format).
9697
- Values in your `.env` file can be overridden from the command line by using [`docker compose run -e`](#set-environment-variables-with-docker-compose-run---env).
9798

9899
## Set environment variables with `docker compose run --env`

content/reference/compose-file/interpolation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Interpolation can also be nested:
3131
Other extended shell-style features, such as `${VARIABLE/foo/bar}`, are not
3232
supported by Compose.
3333

34+
Compose processes any string following a `$` sign as long as it makes it
35+
a valid variable definition - either an alphanumeric name (`[_a-zA-Z][_a-zA-Z0-9]*`)
36+
or a braced string starting with `${`. In other circumstances, it will be preserved without attempting to interpolate a value.
37+
3438
You can use a `$$` (double-dollar sign) when your configuration needs a literal
3539
dollar sign. This also prevents Compose from interpolating a value, so a `$$`
3640
allows you to refer to environment variables that you don't want processed by

content/reference/compose-file/services.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ i.e. overridden to be empty.
618618
env_file: .env
619619
```
620620

621+
Relative paths are resolved from the Compose file's parent folder. As absolute paths prevent the Compose
622+
file from being portable, Compose warns you when such a path is used to set `env_file`.
623+
624+
Environment variables declared in the [environment](#environment) section override these values. This holds true even if those values are
625+
empty or undefined.
626+
621627
`env_file` can also be a list. The files in the list are processed from the top down. For the same variable
622628
specified in two env files, the value from the last file in the list stands.
623629

@@ -627,9 +633,14 @@ env_file:
627633
- ./b.env
628634
```
629635

630-
List elements can also be declared as a mapping, which then lets you set an additional
631-
attribute `required`. This defaults to `true`. When `required` is set to `false` and the `.env` file is missing,
632-
Compose silently ignores the entry.
636+
List elements can also be declared as a mapping, which then lets you set additional
637+
attributes.
638+
639+
#### required
640+
641+
{{< introduced compose 2.24.0 "/manuals/compose/releases/release-notes.md#2240" >}}
642+
643+
The `required` attribute defaults to `true`. When `required` is set to `false` and the `.env` file is missing, Compose silently ignores the entry.
633644

634645
```yml
635646
env_file:
@@ -638,13 +649,21 @@ env_file:
638649
- path: ./override.env
639650
required: false
640651
```
641-
> `required` attribute is available with Docker Compose version 2.24.0 or later.
642652

643-
Relative path are resolved from the Compose file's parent folder. As absolute paths prevent the Compose
644-
file from being portable, Compose warns you when such a path is used to set `env_file`.
653+
#### format
645654

646-
Environment variables declared in the [environment](#environment) section override these values. This holds true even if those values are
647-
empty or undefined.
655+
{{< introduced compose 2.30.0 "/manuals/compose/releases/release-notes.md#2300" >}}
656+
657+
The `format` attribute lets you use an alternative file format for the `env_file`. When not set, `env_file` is parsed according to the Compose rules outlined in [Env_file format](#env_file-format).
658+
659+
`raw` format lets you use an `env_file` with key=value items, but without any attempt from Compose to parse the value for interpolation.
660+
This let you pass values as-is, including quotes and `$` signs.
661+
662+
```yml
663+
env_file:
664+
- path: ./default.env
665+
format: raw
666+
```
648667

649668
#### Env_file format
650669

@@ -1772,13 +1791,26 @@ parameters (sysctls) at runtime](/reference/cli/docker/container/run.md#sysctl).
17721791
`tmpfs` mounts a temporary file system inside the container. It can be a single value or a list.
17731792

17741793
```yml
1775-
tmpfs: /run
1794+
tmpfs:
1795+
- <path>
1796+
- <path>:<options>
17761797
```
17771798

1799+
- <path>: The path inside the container where the tmpfs will be mounted.
1800+
- <options>: Comma-separated list of options for the tmpfs mount.
1801+
1802+
Available options:
1803+
1804+
- `mode`: Sets the file system permissions.
1805+
- `uid`: Sets the user ID that owns the mounted tmpfs.
1806+
- `gid`: Sets the group ID that owns the mounted tmpfs.
1807+
17781808
```yml
1779-
tmpfs:
1780-
- /run
1781-
- /tmp
1809+
services:
1810+
app:
1811+
tmpfs:
1812+
- /data:mode=755,uid=1009,gid=1009
1813+
- /run
17821814
```
17831815

17841816
### tty

0 commit comments

Comments
 (0)