Skip to content

Missing support for variable interpolation in .env files #718

@hashkool

Description

@hashkool

podman-compose deviates from docker-compose in

  • that it does not interpolate strings in .env files, and
  • that it does not know about host env vars in .env (like $HOME, $PWD etc)

To Reproduce

FILE: .env

A=bar
B=foo$A
C=$HOME/foo
D="${XDG_DATA_HOME:-$HOME/.local/share}/blabla"

FILE: docker-compose.yml

version: "4"
services:
    variables:
        image: busybox
        command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
        environment:
            EXAMPLE_SIMPLE: "$B"
            EXAMPLE_HOSTVAR_SIMPLE: $C
            EXAMPLE_HOSTVAR_COMPLEX: $D

Commands

$ podman-compose config

Expected behavior
All the variables should be substituted as you would expect. Note that docker-compose config just works as expected.
Also no need to explicitly pass around variables with -e from when invoking docker-compose.

Actual behavior
Actual behaviour is that $B evaluates to literally foo$A, meaning it doesn't interpolate its value.
$C and $D results in errors, as podman-compose doesn't know about $HOME at all.

Output

$ podman-compose version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
podman-compose version 1.0.6
podman --version 
podman version 4.5.0

Environment:
Linux 6.1.31-2

Additional context

Current tests in repo do not test equality of output between docker-compose and podman-compose. That would possibly make your life easier to keep feature parity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions