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

Changes in .env are not reflected immediately

Open LightSith opened this issue 4 years ago • 4 comments

Describe the bug Not sure if this is expected behavior or not but changes made in .env file are not reflected immediately like they do with docker-compose

To Reproduce Steps to reproduce the behavior:

❯ cat Dockerfile        
from busybox
entrypoint ["sh","-c","env"]
❯ podman image build . -t noiceimg
❯ cat docker-compose.yml
services:
  noiceservice:
    image: noiceimg
    environment:
      f1: $F1

with docker compose, changes made in .env file are immediately reflected each time when I do docker-compose up but with podman-compose up they are not changed.

I have to do podman-compose down and then again podman-compose up for to .env to take effect

Expected behavior similar to docker-compose. environment variable in container are changed with respect to variables in .env file on host

Actual behavior

each time, I have to do podman-compose down for to .env file to take effect

❯ podman-compose version
['podman', '--version', '']
using podman version: 3.4.4
podman-composer version  1.0.3
podman --version 
podman version 3.4.4
exit code: 0

**Environment:**
 - OS: ArchLinux
 - podman version 3.4.4
 - podman-composer version  1.0.3 (installed from arch's repo)


LightSith avatar Jan 22 '22 19:01 LightSith

it's not about .env

same dockerfile with the following docker-compose.yml

services:
  noiceservice:
    build: .
    image: noiceimg
    environment:
      f1: $F1

tested like this

$ echo "F1=4" > .env
$ docker-compose up
Recreating envtest_noiceservice_1 ... done
Attaching to envtest_noiceservice_1
noiceservice_1  | HOSTNAME=31bb3e70916b
noiceservice_1  | SHLVL=1
noiceservice_1  | HOME=/root
noiceservice_1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
noiceservice_1  | f1=4
noiceservice_1  | PWD=/
envtest_noiceservice_1 exited with code 0

each time you touch the env, the hash changes which triggers Recreating

Recreating envtest_noiceservice_1 ... done

currently we don't recreate. we should implement recreate.

muayyad-alsadi avatar Jan 23 '22 13:01 muayyad-alsadi

the latest push tracks the checksum of the compose yaml it's now possible to detect changes and recreate containers.

muayyad-alsadi avatar Feb 26 '22 18:02 muayyad-alsadi

Hello @muayyad-alsadi,

this indeed works as expected for environment variables defined in .yml files, however changes to an env_file are not detected and containers are not recreated

    env_file:
      - .env-docker-app

maromcik avatar Apr 08 '25 08:04 maromcik

@maromcik Please open a new issue and give the exact details of the problem so it can be resolved.

mokibit avatar Nov 27 '25 20:11 mokibit