domain configuration in docker-compose : <p>How to configure hostnames with domains in <code>docker-compose.yml</code>?</p>

<p>Let's say the service <code>worker</code> expects the service <code>web</code> on the <code>http://web.local/</code> address.  But <code>web.local</code> doesn't resolve to an ip address no matter what I configure using the <code>hostname</code> directive. Adding an <code>extra_hosts</code> directive doesn't work either as I should know the ip of the service <code>web</code> for that, which I don't as it is assigned by docker. </p>

<p>docker-compose.yml:</p>

<pre><code>version: '3'
services:
  worker:
    build: ./worker
    networks:
      - mynet    
  web:
    build: ./web
    ports:
      - 80:80
    hostname: web.local
    networks:
      - mynet
networks:
  mynet:
</code></pre>

<p>but <code>ping web.local</code> doesn't resolve inside the service <code>worker</code></p>
