Environment Variables values are not interpolated
Description:
When specifying an environment variable under the services environment section with interpolation (e.g., MYENV=${DEBUG-1}), the container is created with MYENV set to the literal value "${DEBUG-1}" instead of 1 when the DEBUG environment variable is not set.
Steps to Reproduce:
- Define a service in your
docker-compose.ymlfile with an environment variable that uses interpolation:services: myservice: environment: - MYENV=${DEBUG-1} - Ensure the
DEBUGenvironment variable is not set in your shell. - Run
podman-compose up.
Expected Behavior:
The container should be created with MYENV set to 1 when the DEBUG environment variable is not set.
Actual Behavior:
The container is created with MYENV set to the literal value "${DEBUG-1}".
Additional Information:
podman-composeversion: 1.3.0podmanversion: 5.2.2- Operating System:
Linux workspaced50dd4e90744453d-574f885c55-d4494 5.14.0-284.96.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 29 13:37:02 EST 2024 x86_64 x86_64 x86_64 GNU/Linux
Facing the same issue. But a bit different:
Works, prints ¨1¨ when DEBUG env var is not defined on host:
services:
test:
container_name: test
image: docker.io/debian
command: env
environment:
- MYENV=${DEBUG:-1}
Does not work, prints ¨${MYENV:-1}¨:
services:
test:
container_name: test
image: docker.io/debian
command: env
environment:
- MYENV=${MYENV:-1}
Seems to be something circular?
Just tested a similar use-case, it is (was) working in 1.2.0, I can't really tell which MR brought the regression.
I'll be using pip install podman-compose==v1.2.0 for now
I just ran into the same problem, exactly with providing a default for a variable that's supposed to be configurable, so the definition is circular, like:
environment:
MYENV: '${MYENV:-default value}'
If the variable to set and the referenced variable have different names it works fine.