Merge pull request #771 from wgnathanael/environment-precedence

Fix environment variable precedents
This commit is contained in:
Povilas Kanapickas 2024-06-22 20:00:08 +03:00 committed by GitHub
commit e07c28d127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -1804,8 +1804,8 @@ class PodmanCompose:
os.environ.update({ os.environ.update({
key: value for key, value in dotenv_dict.items() if key.startswith("PODMAN_") key: value for key, value in dotenv_dict.items() if key.startswith("PODMAN_")
}) })
self.environ = dict(os.environ) self.environ = dotenv_dict
self.environ.update(dotenv_dict) self.environ.update(dict(os.environ))
# see: https://docs.docker.com/compose/reference/envvars/ # see: https://docs.docker.com/compose/reference/envvars/
# see: https://docs.docker.com/compose/env-file/ # see: https://docs.docker.com/compose/env-file/
self.environ.update({ self.environ.update({

View File

@ -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 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
```