Giter Site home page Giter Site logo

Comments (10)

mag37 avatar mag37 commented on May 27, 2024 1

Hey, and thank you for the suggestion and well described situation!

Currently the script is checking for

ContEnv=$(docker inspect "$i" --format '{{index .Config.Labels "com.docker.compose.project.environment_file" }}')

Then it's started with something similar to this:

docker compose --env-file "$ContEnv" up -d

Maybe this only works a single env-file? And maybe only if declared through the compose-file?
I'll try to do some testing this weekend and see what I can achieve. But if you can/want I'd gladly receive some more info from how things look at your side of this.

What do you get if you run this on a container with multiple env-files?

docker inspect "ContainerABC" --format '{{index .Config.Labels "com.docker.compose.project.environment_file" }}'

(replace ContainerABC)

from dockcheck.

mag37 avatar mag37 commented on May 27, 2024 1

Done some simple testing on my phone and might have a simple solution ready 😅
Just need some further testing.

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 ... --env-file /path/file1.env --env-file /path/file2.env

Is this solving your issue?

from dockcheck.

mag37 avatar mag37 commented on May 27, 2024 1

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.

  1. You'll run dockcheck and choose to update cloudflare-ddns.
  2. The script would then do a check, as docker inspect "cloudflare-ddns" ..... (in the example above)
  3. It will find the env-files:
    /home/buddy/villa-kunterbunt/global.env,/home/buddy/villa-kunterbunt/cloudflare-ddns/local.env
  4. It will then update the container, then start it with:
    docker compose --env /home/buddy/villa-kunterbunt/global.env --env /home/buddy/villa-kunterbunt/cloudflare-ddns/local.env up -d

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.

from dockcheck.

Buddinski88 avatar Buddinski88 commented on May 27, 2024

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.
However, I would also try it again if the script is changed here.
As I understand it so far, the start command only allows one env 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

from dockcheck.

mag37 avatar mag37 commented on May 27, 2024

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.

from dockcheck.

Buddinski88 avatar Buddinski88 commented on May 27, 2024

I don't think I quite understand your approach. I guess I'm on the wrong track 😅
Do you mean that I would maintain a list containing the env files required for the operation of the respective service?

from dockcheck.

Buddinski88 avatar Buddinski88 commented on May 27, 2024

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.
Very cool idea. I could have thought of that after you asked with docker inspect 😊

from dockcheck.

mag37 avatar mag37 commented on May 27, 2024

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.
new branch

If you'd like to test it on one of your containers that'd be awesome!
Just clone/download the dockcheck.sh and try to run it with ./dockcheck.sh cloudflare-ddns or some other container that can handle a couple of seconds downtime if you'd need to restart it manually with your correct --env-file flags if it doesnt start as it should.

from dockcheck.

Buddinski88 avatar Buddinski88 commented on May 27, 2024

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?

from dockcheck.

mag37 avatar mag37 commented on May 27, 2024

Wonderful!
The quick work was thanks to your collaboration and info. Thank you for reporting and testing.

It will close when I merge the branch with main in a bit.

from dockcheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.