Skip to content

Commit

Permalink
Fix environment variable precedents
Browse files Browse the repository at this point in the history
Per https://docs.docker.com/compose/environment-variables/envvars-precedence/#advanced-example

Signed-off-by: nathanael.noblet <nathanael.noblet@willowglensystems.com>
  • Loading branch information
wgnathanael authored and p12tic committed Jun 22, 2024
1 parent 80b2aa6 commit 935029d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,8 +1804,8 @@ def _parse_compose_file(self):
os.environ.update({
key: value for key, value in dotenv_dict.items() if key.startswith("PODMAN_")
})
self.environ = dict(os.environ)
self.environ.update(dotenv_dict)
self.environ = dotenv_dict
self.environ.update(dict(os.environ))
# see: https://docs.docker.com/compose/reference/envvars/
# see: https://docs.docker.com/compose/env-file/
self.environ.update({
Expand Down
6 changes: 6 additions & 0 deletions tests/env-file-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ podman-compose -f $(pwd)/project/container-compose.env-file-obj.yaml up
```
podman-compose -f $(pwd)/project/container-compose.env-file-obj-optional.yaml up
```

based on environment variable precedent this command should give podman-rocks-321

```
ZZVAR1=podman-rocks-321 podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
```

0 comments on commit 935029d

Please sign in to comment.