docker / cli

The Docker CLI
Apache License 2.0
4.75k stars 1.88k forks source link

I believe docker is less functional because SHELL variables take precedence over .env files or --env-file #5093

Open david-zamora-minderest opened 1 month ago

david-zamora-minderest commented 1 month ago

Description

First of all I want to say that I may not be aware of every way to deal with this problem, but as far as I've seen it makes no sense to me. I have just switched to the new docker compose command to find out, that the precedence of environment files changed around a couple of years ago. I have a docker-compose.yml that expect a DENO_PORT environment variable from the .env file to start a Deno app inside the container using the ports 5000:5000. Now, while I am updating the application locally, I need to start the same app in a different port with live reloading. The Application is expecting to get the port from the environment variable DENO_PORT, so... If I set DENO_PORT to 5001 in zshrc and to 5000 in the .env file, it doesn't work anymore. Now it's always the port 5001, I can't have the same variable with different values between my host and my containers, how is that a good idea? Why is it a good practice to have exactly the same?

How is it possible that now I need two variables to accomplish the same thing? Is there something I am missing? How is this better for other user cases?

MishkaMN commented 3 weeks ago

I am also facing similar issue as well. Can someone please explain how I can override the shell variables from HOST in the container gracefully with .env files

david-zamora-minderest commented 3 weeks ago

@MishkaMN it seems to me, that you can't anymore. Since your own host environment variables override those in the container.