<p>I have a pipenv-environment running in a Dockercontainer and I need some variables from a .env file.</p>

<p>The container is running in a Kubernetes pod.</p>

<p>I can't upload the .env file to the repository because the variables in .env are secret.</p>

<p>My question is if there is a way to get my variables from a secret to the .env file. </p>

<p>I tried creating the .env file in my Dockerfile but ran into the problem that I couldn't figure out how to get the variables accessible in the Dockerfile.</p>

<p>This is what I tried in my Dockerfile:</p>

<pre><code>#create .env file for pipenv
RUN echo DATABASE_URL=$DATABASE_URL &gt; .env 
RUN echo API_EMAIL=$API_EMAIL&gt;&gt; .env
RUN echo API_PASSWORD=$API_PASSWORD&gt;&gt; .env
</code></pre>

<p>The three variables get set in a secret and the secret is referenced to the pod. Unfortunately the variables are not accessible.</p>

<p>Does anyone have an idea how I can get the variables from the secret into a .env file in my container? Thanks for any ideas</p>

Florian
<p>move the commands that add entries to .env file from Dockerfile to container startup script before launching the actual container process.</p>

<p>OR</p>

<p>You can create a secret object from key=value pairs and mount it as .env file inside container</p>
