podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

podman-compose no longer parses variables in the specified --env-file file

Open gloryandel opened this issue 1 year ago • 1 comments

Describe the bug Configure APP_DATA=/srv/pool/appdata/${UID} in env file

compose.yaml

services:
  jellyfin:
    image: ghcr.io/jellyfin/jellyfin:latest
    container_name: jellyfin
    volumes:
      - ${APP_DATA}/Jellyfin/config:/config
      - ${APP_DATA}/Jellyfin/cache:/cache
    devices:
      - /dev/dri:/dev/dri
    restart: unless-stopped

podman-compose --env-file <file> config

output

services:
  jellyfin:
    image: ghcr.io/jellyfin/jellyfin:latest
    container_name: jellyfin
    volumes:
      - /srv/pool/appdata//Jellyfin/config:/config
      - /srv/pool/appdata//Jellyfin/cache:/cache
    devices:
      - /dev/dri:/dev/dri
    restart: unless-stopped

Obviously, the environment variables are not working. According to the pod creation date information "Created": "2024-11-21T13:24:38.787538597+08:00" that was deployed before and the environment variables worked normally, this problem should be caused by the recent update.

When I deployed the container as before, I found that the results were inconsistent with the previous ones.

Actual behavior

    volumes:
      - /srv/pool/appdata/1000/Jellyfin/config:/config
      - /srv/pool/appdata/1000/Jellyfin/cache:/cache

Output

$ podman-compose version podman-compose version 1.2.0 podman version 5.3.1

Environment:

  • OS: ArchLinux Linux Arc 6.12.1-arch1-1 Fri, 22 Nov 2024 16:04:27 +0000 x86_64 GNU/Linux podman-compose version 1.2.0 podman version 5.3.1

gloryandel avatar Dec 01 '24 16:12 gloryandel

I have the same issue on debian 12, using http://download.opensuse.org/repositories/home:/alvistack/Debian_12/ Same versions podman-compose version 1.2.0 podman version 5.3.1

.env is ignored regardless of if --env-file is set or not

I found the reason it is because of - ENV_VAR syntax. - ENV_VAR=${ENV_VAR} works properly. Please add the support for short form

0xCA avatar Jan 05 '25 14:01 0xCA

@Gloryandel Thank you for opening this issue! I attempted to reproduce your problem using the following minimal configuration, with no success:

  1. compose.yml file:
services:
  test:
    image: busybox
    volumes:
      - ${APP_DATA}/test/config:/config
  1. .env file (located in a different directory from compose.yml):
APP_DATA=/dir/${KDE_SESSION_UID}
  1. Versions:
podman-compose version 1.4.0
podman version 4.9.3

When I ran the command podman-compose --env-file /path/to/.env config, the output was:

services:
  test:
    image: busybox
    volumes:
    - /dir/1000/test/config:/config

The output is consistent with the output of docker-compose. It is evident that the .env file successfully takes the KDE_SESSION_UID environment variable from the shell's environment variables. podman-compose then interpolates the KDE_SESSION_UID value to create the APP_DATA environment variable, which is further interpolated in the compose.yml file.

Please update your podman-compose to the latest main, it should work as expected.

Important: make sure that the relevant environment variable actually exists in your shell's environment variables, as the .env file collects the variables from there. For example,.env file:

APP_DATA=/dir/${THIS_VAR_DOES_NOT_EXIST}

Output of podman-compose --env-file /path/to/.env config (looks similar to yours!):

services:
  test:
    image: busybox
    volumes:
    - /dir//test/config:/config

docker-compose gives a similar output of config command (<...> source: /dir//test/config <...>) and also a verbose error:

WARN[0000] The "THIS_VAR_DOES_NOT_EXIST" variable is not set. Defaulting to a blank string. 

Explaining why empty string was sent to APP_DATA value.

mokibit avatar Jun 26 '25 15:06 mokibit

@p12tic I this this issue can be closed.

mokibit avatar Jun 26 '25 15:06 mokibit

I found the reason it is because of - ENV_VAR syntax. - ENV_VAR=${ENV_VAR} works properly. Please add the support for short form

@0xCA issue regarding short variable syntax was resolved by #1248. Please update your podman-compose to the latest main, it should work as expected. If you see any other issues, please open a new bug report.

mokibit avatar Jun 26 '25 16:06 mokibit

Tested again, works fine.

gloryandel avatar Jun 27 '25 02:06 gloryandel