Proper way to load ENV from a file when using Docker

Is there a good way to load ENV vars from a file? For CI and local dev, we commit these to git, as they don’t contain anything private. I would rather read them from here than set them in the docker environment settings like

- image: circleci/python:3.6
    environment:
        REDIS_URL: localhost

It would keep the number of places where configuration resides if I didn’t also have to do it here. Thanks!

Hmm, interesting. You can certainly commit an .env file to your repo, but to use that you’d need to copy it into place first in a run step, and the image you’re referring to will be spun up as a container prior to any of your steps being run.

If this is a primary container, you can of course use source in a run step. However, if it is a secondary container, that’s a bit harder - one solution to that is to abandon multiple containers at the CircleCI level and launch them yourself in Docker Compose.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.