title: How to provide ENV variable from k8s to a python app during the docker run
body: <p>I have a docker file in which I am hardcoding the env variables for now as it gets injected in the app during the build process. Now, I want to inject those during the runtime when the application gets ran in the k8s pod. I tried <a href="https://stackoverflow.com/questions/64354568/pip-install-failing-on-kubernetes-pod">this</a> but its not working. Below is my docker file. Its my first time using serious python and am not sure how to fix it.</p>
  <pre><code>FROM python:3.7-slim AS build
  
  WORKDIR /app
  
  COPY . .
  
  RUN python3 setup.py bdist_wheel
  
  #ENV USE_DB=&quot;True&quot; \
  #   DB_USERNAME= \
  #   DB_HOST= \
  #   DB_PASSWORD= \
  #   DB_DB=sth
  RUN pip3 install dist/app_search*.whl &amp;&amp; \
      semanticsearch-preprocess
  
  FROM python:3.7-slim
  
  WORKDIR /opt/srv
  
  COPY --from=build /app/dist/app_search*.whl /opt/srv/
  
  COPY --from=build /tmp/projects* /opt/srv/
  
  # set environment variables to /opt/srv
  ENV DICT_FILE=&quot;/opt/srv/projects.dict&quot; \
      MODEL_FILE=&quot;/opt/srv/projects.model.cpickle&quot; \
      INDEX_FILE=&quot;/opt/srv/projects.index&quot; \
      EXTERNAL_INDEX_FILE=&quot;/opt/srv/projects.mm.metadata.cpickle&quot;
  
  
  RUN pip3 install waitress &amp;&amp; \
      pip3 install app_search*.whl
  
  EXPOSE 5000
  
  ENTRYPOINT [ &quot;waitress-serve&quot; ]
  
  CMD [ &quot;--call&quot;, &quot;app_search.app:main&quot; ]
  </code></pre>