title: Docker Swarm, how to communicate to other services through their "hostname" only?
body: <p>I have some experience with Docker Compose and container linking. In a non-swarm environment, you could easily connect from, e.g, the <code>web</code> container to the <code>db_mysql</code> container using its name (for example, in PHP I can configure the MySQL connection to be:</p>
  
  <p><code>$dsn = 'mysql:host=db_mysql;</code></p>
  
  <p>I am having a hard time understanding how that works with Docker in Swarm mode, especially considering the "replicas" and "load balancing" mechanisms.</p>
  
  <p>Let's say I have 5 different Docker Machines, each having a different public IP, participating in a Swarm. I also have a <code>web</code> service and a <code>db</code> service that's replicated across these 5 different machines (1 instance per each machine).</p>
  
  <p>My question is: how do I make any of the 5 <code>web</code> containers, communicate to any of the 5 <code>db_mysql</code> containers without forcing these <code>web</code> containers to have knowledge of any Docker Machine public IPs or the fact that these containers live within a Swarm?</p>