title: Environment variables passed to docker run
body: <p>I have a docker image which is partially ready to work. To have it fully working I have to run</p>
  
  <pre><code>sudo docker run -d -p 80 --name myimage -e ADMIN_USER="user1" -e ADMIN_PASSWORD='password1' leonixyz/myimage:1.0
  </code></pre>
  
  <p>The first time the image gets executed my code configures the application inside.</p>
  
  <p>This is handy because each time I need a new instance of the application, which has to be configured each time for a different user, I can pass different environment variables to <code>docker run</code> and my code will configure the container specifically for the new user.</p>
  
  <p>Unfortunately, I see these variables cannot be removed from the container. </p>
  
  <p>If I do:</p>
  
  <pre><code>sudo docker exec -it &lt;container_id&gt; bash
  </code></pre>
  
  <p>then I can see variables <code>ADMIN_USER</code> and <code>ADMIN_PASSWORD</code> are (obviously) still there.</p>
  
  <p>I tried to <code>unset ADMIN_PASSWORD</code> on the end of my one-time-configuration code, but it doesn't work.</p>
  
  <p>Also running <code>unset ADMIN_PASSWORD</code> from the bash shell in the running container won't work.</p>
  
  <p>Is there a way to remove an environment variable from a container, once this has been started?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><strong>Edit</strong>
  as pointed out it's better to not pass secrets at all via environment variables, a great workaround is explained here <a href="https://github.com/docker/docker/issues/13490#issuecomment-162125128" rel="noreferrer">https://github.com/docker/docker/issues/13490#issuecomment-162125128</a></p>