Skip to content

Support variable interpolation in service env_file files - #1510

Open
mokibit wants to merge 2 commits into
containers:mainfrom
mokibit:env-file-interpolation
Open

Support variable interpolation in service env_file files#1510
mokibit wants to merge 2 commits into
containers:mainfrom
mokibit:env-file-interpolation

Conversation

@mokibit

@mokibit mokibit commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Before service-level env_file files did not interpolate variables from the project's .env file (or --env-file), and the $VAR syntax (without braces) was completely unsupported.
Now both ${VAR} and $VAR syntaxes work in service env_file files, with compose-level variables available for interpolation. This aligns podman-compose behavior with Docker Compose.

Fixes #848.

Comment thread tests/unit/test_container_to_args.py Outdated
Comment thread tests/unit/test_container_to_args.py Outdated
Comment thread podman_compose.py Outdated
Comment thread podman_compose.py Outdated
@mokibit
mokibit force-pushed the env-file-interpolation branch 3 times, most recently from 047f27a to e38a48a Compare August 25, 2026 09:21
Before service-level `env_file` files did not interpolate variables from
the project's `.env` file (or `--env-file`). Now `${VAR}` syntax works
in service `env_file` files, with compose-level variables available for
interpolation. This aligns `podman-compose` behavior with Docker
Compose.

Signed-off-by: Monika Kairaityte <monika@kibit.lt>
This commit extends interpolation support to also recognize the bare
`$VAR` syntax (without braces), which docker-compose accepts.

A preprocessing step rewrites bare `$VAR` into `${VAR}` before
python-dotenv parses the file, so the existing interpolation logic works
for both syntaxes. Escaped `$$VAR` is preserved as a literal `$VAR`,
and single-quoted values are left untouched.

Signed-off-by: Monika Kairaityte <monika@kibit.lt>
@mokibit
mokibit force-pushed the env-file-interpolation branch from e38a48a to ca17dca Compare August 25, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

env_file: does not match docker-compose's behavior

2 participants