title: Docker-compose not passing environment variable to container
body: <p>I am using Docker 17.04.0-ce, build 4845c56 with docker-compose 1.12.0, build b31ff33 on Ubuntu 16.04.2 LTS. I simply want to pass an environment variable and display it from my script running in a container. I am doing this according to the documentation <a href="https://docs.docker.com/compose/compose-file/#environment" rel="nofollow noreferrer">https://docs.docker.com/compose/compose-file/#environment</a> . The problem is that the variable is not passed to the container.</p>
  
  <p>My docker-compose.yml file:</p>
  
  <pre><code>env-file-test:
    build: .
    dockerfile: Dockerfile
    environment:
      - DEMO_VAR
  </code></pre>
  
  <p>My Dockerfile:</p>
  
  <pre><code>FROM alpine
  COPY docker-start.sh /
  CMD ["/docker-start.sh"]
  </code></pre>
  
  <p>And the <code>docker-start.sh</code> file:</p>
  
  <pre><code>#!/bin/sh
  echo "DEMO_VAR Var Passed in: $DEMO_VAR"
  </code></pre>
  
  <p>I try to set the variable in my current terminal session and pass it to the container:</p>
  
  <pre><code>$ export DEMO_VAR=aabbdd
  $ echo $DEMO_VAR
  aabbdd
  $ sudo docker-compose up
  Starting envfiletest_env-file-test_1
  Attaching to envfiletest_env-file-test_1
  env-file-test_1  | DEMO_VAR Var Passed in: 
  envfiletest_env-file-test_1 exited with code 0
  </code></pre>
  
  <p>So you can see that the variable DEMO_VAR is empty!</p>
  
  <p>I also tried using variables in docker-compose.yml like this: <code>DEMO_VAR=${DEMO_VAR}</code> but then when I run <code>sudo docker-compose up</code>, I get a warning: "WARNING: The DEMO_VAR variable is not set. Defaulting to a blank string.".</p>
  
  <p>What am I doing wrong? What should I do to pass the variable to the container?</p>