title: Host environment variables with docker stack deploy
body: <p>I was wondering if there is a way to use environment variables taken from the host where the container is deployed, instead of the ones taken from where the <code>docker stack deploy</code> command is executed. For example imagine the following <code>docker-compose.yml</code> launched on three node Docker Swarm cluster:</p>
  
  <pre><code>version: '3.2'
  services:
    kafka:
      image: wurstmeister/kafka
      ports:
        - target: 9094
          published: 9094
          protocol: tcp
          mode: host
      deploy:
        mode: global
      environment:
        KAFKA_JMX_OPTS: "-Djava.rmi.server.hostname=${JMX_HOSTNAME} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=1099"
  </code></pre>
  
  <p>The <code>JMX_HOSTNAME</code> should be taken from the host where the container is actually deployed and should not be the same value for every container. 
  Is there a correct way to do this?</p>