title: Set hostname of service container to host's hostname
body: <p>I run a docker swarm with docker swarm mode. Let's say I have 4 nodes, 1 manager, 3 worker. The hostnames are:</p>
  
  <ul>
  <li>manager0</li>
  <li>worker0</li>
  <li>worker1</li>
  <li>worker2</li>
  </ul>
  
  <p>I start the service in <code>global</code> mode, so every node runs the service once. 
  Let's say the command looks like this:</p>
  
  <pre><code>docker service create --name myservice --mode global --network mynetwork ubuntu wait 3600
  </code></pre>
  
  <p><code>mynetwork</code> is an overlay network.</p>
  
  <p>Now I am trying to access the hostname of the docker host in the containers, so I can pass the hostname to an application in the container.</p>
  
  <p>I tried to pass the hostname with the environment variables (<code>--env hostname=$(hostname)</code>), but actually <code>${hostname}</code> is only executed on the manager and the hostname is set to <code>manager0</code> for all nodes. </p>
  
  <p>Is there a way to access the hostname or pass the hostname to the containers? </p>