title: How to set environment variables in Windows Command Prompt so they’re passed in `docker run -e FOO -e …` like with bash export
body: <p>Is there a Windows equivalent to bash's <code>export</code>? I want to set an environment variable so that it's available to subsequent commands. I <em>don't</em> want to <code>setx</code> a permanent env variable.</p>
  <p>For example this works as expected with Docker for Windows in a Windows Terminal PowerShell Command Prompt. The <code>FOO</code> environment variable value is available in the container.</p>
  <pre><code>PS C:\Users\Owner&gt; docker run -e FOO=bar centos env
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=05b90a09d7fd
  FOO=bar
  HOME=/root
  </code></pre>
  <p>But how do I set an env variable in Windows with the equivalent of bash export so that it’s available <em>without</em> setting the value directly on each docker run command?
  You can see here that <code>set</code> does not pass the value of <code>FOO</code> to the container.</p>
  <pre><code>PS C:\Users\Owner&gt; set FOO=bar
  PS C:\Users\Owner&gt; docker run -e FOO centos env
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=6642033b3753
  HOME=/root
  </code></pre>
  <p>I know I can create an env file and pass that to <code>docker run</code> but I'm trying to avoid that.</p>
  <p>PS: I asked this question here but didn't get an answer:
  <a href="https://forums.docker.com/t/how-to-set-environment-variables-in-command-prompt-so-theyre-passed-in-docker-run-e-foo-e/106776/4" rel="nofollow noreferrer">https://forums.docker.com/t/how-to-set-environment-variables-in-command-prompt-so-theyre-passed-in-docker-run-e-foo-e/106776/4</a></p>