I am trying to use a single Docker file for my production and development. The only difference between production and development is the environment variables that I set. Therefore, I would like to somehow import environment variables from a file. Before using Docker, I just do the following
. ./setvars ./main.py
However, if the change is ./main.py with the equivalent of Docker
. ./setvars docker run .... ./main.py
then the variables will be on the host and not accessible from the Docker instance. Of course, a quick and dirty hack would be to create a file with
and run this on the instance. This, however, would be very unpleasant, since I had many scripts that I would like to run (with the same environment variables), and then you will have to create an additional script for each of them.
Is there any other solution for getting environment variables inside dockers without using another Docker file and the method described above?
source share