Hi !
I'm using docker compose for my project.
All my api keys are stored in a local file (ignored by git) and I inject it into my project with env_file
in my docker-compose.yml
.
Most of those variables are only for production, you can run the project with the file empty.
The problem is, I can't start my container if the file doesn't exist.
It could be a good idea to add a parameter to env_file to make it optional.
Cheers !
Dorian
What about creating an empty file? A lot less surprising than accepting non-existing environment variable files.
That's what we do indeed, but I think an empty file is worse than a non-existent file (with a warning)
I too would like support for letting the execution through when an env_file doesn't exist. Some of the tasks in docker-compose are not executed and if the env_file of those non-executed tasks don't exist, who cares? It should not prevent me from moving forward.
It's a pain in the arse!
I would also agree on this one, I would propose creating a warning, in a similar way we do if an environment $variable
exists in a docker-compose.yaml
file, but is not included in the current environment.
I could draft a PR if this is a behaviour we agree upon.
The upsides I see on such an implementation are:
.env
files are ignored)Yes please! This would greatly improve the process of adding new env_files. The song-and-dance currently necessary to create dummy env files is annoying (getting a file into the Git repo but then making sure changes aren't tracked).
@akalipetis That implementation you described sounds perfect to me.
Closing, see https://github.com/docker/compose/pull/3955#issuecomment-341231156 for rationale.
Can this be reconsidered? Having to touch
dummy .env
files in a ton of release pipelines adds a ton of overhead.
I faced the same issues as well and I have to create the dedicated docker compose for the local dev. This is not convenient at all. It found be nice if env_files be optional as @akalipetis suggested
Most helpful comment
Yes please! This would greatly improve the process of adding new env_files. The song-and-dance currently necessary to create dummy env files is annoying (getting a file into the Git repo but then making sure changes aren't tracked).