title: Override variables in docker-compose env_file with the actual environment from the outside
body: <p>Given a very simple <a href="https://docs.docker.com/compose/" rel="noreferrer">docker-compose</a> file:</p>
  
  <pre><code>version: '3'
  
  services:
    test:
      image: busybox
      env_file:
        - my.env
      command: env
  </code></pre>
  
  <p>And the <code>my.env</code> file referenced in there:</p>
  
  <pre><code>FOO=BAR
  </code></pre>
  
  <p>Running <code>docker-compose up</code> prints as expected (container name prefix defaults to the name of the parent directory):</p>
  
  <pre><code>test_1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  test_1  | HOSTNAME=00dc4fa7f38a
  test_1  | FOO=BAR
  test_1  | HOME=/root
  tmp_test_1 exited with code 0
  </code></pre>
  
  <p>Overriding the variable from the <code>env_file</code> from the outside, as in <code>FOO=SOMETHING_ELSE docker-compose up</code>, will not be reflected in the container though. The output will still contain <code>FOO=BAR</code> as defined in the <code>my.env</code>.</p>
  
  <p>Is it possible somehow to override variables defined in the <code>env_file</code> from the outside, without changing them inside the file? I know that it will work if I extend my <code>docker-compose.yml</code> file with the line</p>
  
  <pre><code>environment:
    - FOO
  </code></pre>
  
  <p>However, this does not really scale to a larger amount of variables - one always has to make sure that the <code>env_file</code> and <code>docker-compose.yml</code> are in sync to prevent nasty bugs.</p>