mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-16 08:38:04 +02:00
Load .env from Compose file's directory and cwd
This commit loads dotenv `.env` (exactly that name) from the following location (the later takes precedence): - The `.env` file in the Compose file's directory. - The `.env` file in the current working directory (invoking podman-compose). This preserves the behavior prior to 1.1.0 and to match with Docker Compose CLI. Fix: https://github.com/containers/podman-compose/issues/937 Signed-off-by: Genzer <732937+Genzer@users.noreply.github.com>
This commit is contained in:
committed by
Povilas Kanapickas
parent
84f7fdd7da
commit
4e9f76768c
@ -25,3 +25,13 @@ based on environment variable precedent this command should give podman-rocks-32
|
||||
```
|
||||
ZZVAR1=podman-rocks-321 podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
|
||||
```
|
||||
|
||||
_The below test should print three environment variables_
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.load-.env-in-project.yaml run --rm app
|
||||
|
||||
ZZVAR1=This value is overwritten by env-file-tests/.env
|
||||
ZZVAR2=This value is loaded from .env in project/ directory
|
||||
ZZVAR3=This value is loaded from env-file-tests/.env
|
||||
```
|
||||
|
@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
environment:
|
||||
ZZVAR1: $ZZVAR1
|
||||
ZZVAR2: $ZZVAR2
|
||||
ZZVAR3: $ZZVAR3
|
Reference in New Issue
Block a user