title: Using environment variable for volume name in docker compose
body: <p>I am using docker compose version 3.3 and want to use environment variable to define the volume name. I looked at a related <a href="https://stackoverflow.com/questions/29377853/how-to-use-environment-variables-in-docker-compose">question</a>, but that seems to be quite old. With long syntax supported in 3.2, is there a way to achieve that?
  Here is what I tried in my docker compose file:</p>
  
  <pre><code>version: '3.3'
  services:
    target:
      image: "my-registry/my-image:${IMAGE_TAG}"
      volumes:
          - type: volume
            source: ${VOLUME_NAME}
            target: /data
      ports:
       - "${TOMCAT_PORT}:8080"
  
  volumes:
    ${VOLUME_NAME}:
  </code></pre>
  
  <p>Obviously this syntax does not work as volume name is not substituted in the keys and throws the following error:</p>
  
  <blockquote>
    <p>volumes value Additional properties are not allowed ('${VOLUME_NAME}'
    was unexpected)</p>
  </blockquote>
  
  <p>Any help will be much appreciated.</p>