title: How to Use Environment Variables in a .env file to fill out other environment variable in the same .env file
body: <p>I am using a base.env as an env_file for several of my docker services.In this base.env I have several parts of the environment variable that repeat throughout the file. For example, port and ip are the same for three different environment variables.
  I would like to specify these in an environment variable and reuse those variables to fill out the other environment variables.</p>
  
  <p>Here is base.env:</p>
  
  <pre><code>### Kafka
  # kafka's port is 9092 by default in the docker-compose file
  KAFKA_PORT_NUMBER=9092
  KAFKA_TOPIC=some-topic
  KAFKA_IP=kafka
  KAFKA_CONN: //$KAFKA_IP:$KAFKA_PORT_NUMBER/$KAFKA_TOPIC
  # kafka topic that is to be created. Note that ':1:3' should remain the same.
  KAFKA_CREATE_TOPICS=$KAFKA_TOPIC:1:3
  # the url for connecting to kafka
  KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://$KAFKA_IP:$KAFKA_PORT_NUMBER
  </code></pre>
  
  <p>I have tried writing</p>
  
  <pre><code>KAFKA_CONN: //$${KAFKA_IP}:$${KAFKA_PORT_NUMBER}/$${KAFKA_TOPIC}
  </code></pre>
  
  <p>in the environment section of the appropriate service in the docker-compose.yml, but this gets interpreted as a literal string in the container.</p>
  
  <p>Is there a way to do what I want in the base.env file?
  Thank you for your help!</p>