Re-using environment variables in docker-compose.yml
<p>Is it possible to re-use environment variables that are shared among multiple containers?</p>
<p>The idea is to avoid duplication, as illustrated in this example:</p>
<pre class="lang-yaml prettyprint-override"><code>version: '2'

services:

  db:
    image: example/db
    ports:
      - &quot;8443:8443&quot; 
    container_name: db
    hostname: db
    environment:
      - USER_NAME = admin 
      - USER_PASSWORD = admin 

svc:
  image: example/svc
  depends_on:
    - db
  ports:
    - &quot;9443:9443&quot;
  container_name: svc
  hostname: svc
  environment:
    - DB_URL = https://db:8443
    - DB_USER_NAME = admin
    - DB_USER_PASSWORD = admin 
</code></pre>