-
Notifications
You must be signed in to change notification settings - Fork 36
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
[FEATURE REQUEST] Add option do define/use multiple .env-files #61
Comments
Hey, and thank you for the suggestion and well described situation! Currently the script is checking for
Then it's started with something similar to this:
Maybe this only works a single env-file? And maybe only if declared through the compose-file? What do you get if you run this on a container with multiple env-files?
(replace ContainerABC) |
Sure, I'd be happy to give you more insights. Basically, I don't have any labels for the .env files within docker-compose.yml. I've had some problems with the paths (even if it's only one folder up). That's why I include the files directly when starting the individual compose file. Here is an example of what docker inspect returns for me when both .env files are given at startup: docker inspect "cloudflare-ddns" --format '{{index .Config.Labels "com.docker.compose.project.environment_file" }}'
/home/buddy/villa-kunterbunt/global.env,/home/buddy/villa-kunterbunt/cloudflare-ddns/local.env |
Thank you thats great info! So the grab of the current env files seems correct. But you're right the current way only include 1 env file and maybe breaks due to the comma separated list of current files. I'll do some testing when I have time and see if I can adjust the logic. Thank you. |
Done some simple testing on my phone and might have a simple solution ready 😅 But that is not adding the option for custom setting of env-files on the fly, but rather using the list like your test above and just starting the container again with all env-files with Is this solving your issue? |
I don't think I quite understand your approach. I guess I'm on the wrong track 😅 |
No sorry, I was unclear. What the "new version" would do is just look up your specific containers current .env-files and then start that same container with the same .env-files. I'll describe with your sample above.
No matter how many env files or in which order you've specified them, no matter if they're defined in the compose-file itself or by --env flag. |
Ok, now I've understood. Of course that would be ideal and would cover my case 100%. At least as far as I've seen so far. |
Wonderful! I've put together a new branch with the adjustments. I've tried it on a few test-containers and it seems to work as planned. If you'd like to test it on one of your containers that'd be awesome! |
That's brilliant. I have just tested it with different services and it always started with the same env files. Even an update with a new image and subsequent start went through without any problems. Thank you very much for the quick help and solution to my enquiry 😊 Are you closing the issue? |
Wonderful! It will close when I merge the branch with main in a bit. |
Hi mag37,
first of all, thank you for the well thought-out script. It has directly replaced Watchtower for me and one function is currently missing for my setup.
Is it possible to add the option to the script to specify the file names of the .env files myself and, ideally, more than one?
The background. I have a
global.env
andlocal.env
.As the name suggests, the
global.env
contains variables that can apply to all services.The
local.env
is specific to the respective service.The file structure looks like this:
Not every service requires a global. or local.env, so the command to start the service always varies:
Many thanks and best regards,
Buddinski88
The text was updated successfully, but these errors were encountered: