title: how to overwrite environment variable in running docker container
body: <p>I am trying to understand method to overwrite environment variable inside running docker container.</p>
  <p>I tried below options as suggested over other SO posts. Every time I set env variable via <code>docker exec -e</code> it shows me env variable as set. On the very next run it disappears.</p>
  <p>Command to start docker:</p>
  <pre><code>docker run -itd --rm -e VAR1=test_var1 -e VAR2=test_var2  --name &quot;test&quot; phusion/baseimage:18.04-1.0.0
  </code></pre>
  <p>Running docker exec to set env variables</p>
  <pre><code>cloud_user@vijaygharge1c:/var/lib/docker$ docker exec -it -e VAR4=test_var4 test env
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=de9cf4253ae9
  TERM=xterm
  VAR1=test_var1
  VAR2=test_var2
  DEBIAN_FRONTEND=teletype
  LANG=en_US.UTF-8
  LANGUAGE=en_US:en
  LC_ALL=en_US.UTF-8
  VAR4=test_var4
  HOME=/root
  cloud_user@vijaygharge1c:/var/lib/docker$ docker exec -it -e VAR4=test_var4 test env | grep VAR
  VAR1=test_var1
  VAR2=test_var2
  VAR4=test_var4
  cloud_user@vijaygharge1c:/var/lib/docker$ docker exec -it -e VAR3=test_var3 test env | grep VAR
  VAR1=test_var1
  VAR2=test_var2
  VAR3=test_var3
  cloud_user@vijaygharge1c:/var/lib/docker$ 
  </code></pre>
  <p>Docker version:</p>
  <pre><code>cloud_user@vijaygharge1c:/var/lib/docker$ docker -v
  Docker version 19.03.12, build 48a66213fe
  cloud_user@vijaygharge1c:/var/lib/docker$ 
  </code></pre>