title: Docker Compose doesn't seem to read env variables defined in env file
body: <p>I have the following project directory structure:</p>
  <pre><code>myapp/
      docker/
          docker-compose.yml
      .env
      src/
          &lt;my source code here&gt;
      config.properties
  </code></pre>
  <p>Here is my <code>.env</code> file:</p>
  <pre><code>ENV=local
  SERVICE_DB_HOST=0.0.0.0
  SERVICE_DB_PORT=3306
  SERVICE_DB_ROOT_PASSWORD=12345
  SERVICE_DB_APP_USER=my-service-user
  SERVICE_DB_APP_PASSWORD=23456
  </code></pre>
  <p>Here is my <code>docker/docker-compose.yml</code>:</p>
  <pre><code>version: &quot;3.7&quot;
  services:
    myapp-main-db:
      env_file:
        - ../.env
      image: mysql:8
      container_name: myapp-main-db
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      ports:
        - $SERVICE_DB_PORT:$SERVICE_DB_PORT
      environment:
        MYSQL_ROOT_PASSWORD: $SERVICE_DB_ROOT_PASSWORD
        MYSQL_DATABASE: myapp_service_db_$ENV
        MYSQL_USER: $SERVICE_DB_APP_USER
        MYSQL_PASSWORD: $SERVICE_DB_APP_PASSWORD
      volumes:
        - myapp-service-db-data:/var/lib/mysql
  volumes:
    myapp-service-db-data:
  </code></pre>
  <p>When I run <code>docker-compose -f docker/docker-compose.yml up -d</code> from the project root directory, I see the MySQL container spin up without issue, and verify its running via <code>docker ps</code>.</p>
  <p><strong>However</strong> I am unable to connect to it using the expected connection string and credentials, which I am <strong>sure</strong> are correct. This leads me to believe that Docker Compose is not loading the <code>../.env</code> file as I was expecting it to, and so none of the variables defined in <code>../.env</code> are being injected as env vars.</p>
  <p><strong>Can anybody spot where I'm going awry?</strong></p>
  <h3>Update</h3>
  <p>When I run <code>docker-compose config</code> I get:</p>
  <pre><code>$ docker-compose config
  WARNING: The SERVICE_DB_PORT variable is not set. Defaulting to a blank string.
  WARNING: The SERVICE_DB_ROOT_PASSWORD variable is not set. Defaulting to a blank string.
  WARNING: The ENV variable is not set. Defaulting to a blank string.
  WARNING: The SERVICE_DB_APP_USER variable is not set. Defaulting to a blank string.
  WARNING: The SERVICE_DB_APP_PASSWORD variable is not set. Defaulting to a blank string.
  ERROR: The Compose file './docker-compose.yml' is invalid because:
  services.myapp-main-db.ports contains an invalid type, it should be a number, or an object
  </code></pre>