Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when use env_file and environments at the same time #11799

Closed
fzn0x opened this issue May 7, 2024 · 2 comments
Closed

Add warning when use env_file and environments at the same time #11799

fzn0x opened this issue May 7, 2024 · 2 comments

Comments

@fzn0x
Copy link

fzn0x commented May 7, 2024

Description

Can we add warning when we use env_file and environments at the same time? env_file will not work and environments will use default .env instead.

For most people, this is really waste time and I've seen so many Issues and Stackoverflow posts talking about this, I think adding a warning could solve the problem.

@fzn0x
Copy link
Author

fzn0x commented May 7, 2024

service will use env_file:

  skphonesmart:
    image: name:tag
    env_file:
      - .env.production.local
    ports:
      - 3001:3001
    restart: always
    depends_on:
      - postgres_server
      - adminer
    networks:
      - adminer-network

service will ignore env_file:

  skphonesmart:
    image: name:tag
    env_file:
      - .env.production.local
    environment:
      MY_PUBLIC_KEY: ${MY_PUBLIC_KEY}
    ports:
      - 3001:3001
    restart: always
    depends_on:
      - postgres_server
      - adminer
    networks:
      - adminer-network

@ndeloof
Copy link
Contributor

ndeloof commented May 13, 2024

There's no reason to warn user about this, both are valid and there's many relevant scenario where user will use both.

service will ignore env_file

it won't, but environment has precedence so same value in env_file will be ignored. Still other variables will be used.
See https://docs.docker.com/compose/environment-variables/set-environment-variables/#additional-information-2

@ndeloof ndeloof closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants