title: How do I create a .env file in Docker
body: <p>I'm quite new to Docker and .Net Core (been using .Net Framework for ages).</p>
  <p>I've created a new .Net Core 3 app and set it to use Docker and the app builds and runs. So far so good.
  This app needs to connect to GoogleBigQuery and, as such, needs the Google Cloud credentials to be stored in an environment variable (took a frustrating hour to realise that Docker doesn't use the Windows environment variables).</p>
  <p>From what <a href="https://docs.docker.com/compose/environment-variables/#the-env-file" rel="nofollow noreferrer">I've</a> <a href="https://docs.docker.com/compose/env-file/" rel="nofollow noreferrer">been</a> <a href="https://www.techrepublic.com/article/how-to-use-docker-env-file/" rel="nofollow noreferrer">reading</a>, I would just add them to the .env file, but I don't have one in my project directory.</p>
  <p>I've tried using the command line to set them like this <code>docker run containername:dev --env VAR1=value1</code> but I get the following error:</p>
  <blockquote>
  <p>docker: Error response from daemon: OCI runtime create failed:
  container_linux.go:367: starting container process caused: exec: &quot;-e&quot;:
  executable file not found in $PATH: unknown.</p>
  </blockquote>
  <p>I've also seen references to the <code>docker-compose.yml</code> file.</p>
  <p>I've tried creating the .env file and tried (unsuccessfully) using the CLI to associate it with the container as follows:</p>
  <pre><code>docker run -i containername:dev --env-file .env
  docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: &quot;--env-file&quot;: executable file not found in $PATH: unknown.
  </code></pre>
  <p>So I'm not sure where to go from here. Everything I've read seems to assume that you already have a .env and I can't find anything around creating a .env manually. I did create a docker-compose.yml file which I was hoping Docker would recognise and subsequently find the .env:</p>
  <pre><code>version: '3.5'
  
  services:
    fms-techmobile-utilities:
      build:
        context: .
        dockerfile: Local.Dockerfile
      image: foo
      container_name: foo
      restart: unless-stopped
      env_file:
        - .env
  </code></pre>
  <p>The above didn't work, so I really don't know what else to try. I did try stopping and restarting the Docker container in the hopes that it would find the yml and env files, but nope</p>