title: Docker-compose multiple services listen on same port, different domains
body: <p>How can I have multiple docker services listening on same ports, only using different domains?</p>
  <p>Is it even possible to define in <code>docker-compose</code> or do I need to have just one service listening on the port and then rerouting the traffic to respective services depending on the domain?</p>
  <hr />
  <p>This example is failing since it's listening on the whole network (instead of just the domains)</p>
  <pre><code>docker-compose up
  Creating network &quot;test-docker_default&quot; with the default driver
  Creating test-docker_static_1 ... done
  Creating test-docker_app_1    ... 
  Creating test-docker_app_1    ... error
  
  ERROR: for test-docker_app_1  Cannot start service app: driver failed programming external connectivity on endpoint test-docker_app_1 (ef433ffad1af01ffa31cd8a69a8c15b69ca7e7b6935924d34891b92682570e68): Bind for 0.0.0.0:80 failed: port is already allocated
  
  ERROR: for app  Cannot start service app: driver failed programming external connectivity on endpoint test-docker_app_1 (ef433ffad1af01ffa31cd8a69a8c15b69ca7e7b6935924d34891b92682570e68): Bind for 0.0.0.0:80 failed: port is already allocated
  </code></pre>
  <p><em>docker-compose.yml</em></p>
  <pre><code>version: '3.3'
  services:
  
    app:
      image: node
      depends_on:
        - static
      networks:
        default:
          aliases:
            - app.localhost
      ports:
        - 80:80
  
    static:
      image: nginx
      networks:
        default:
          aliases:
            - static.localhost
      ports:
        - 80:80
  </code></pre>
  <p><em>/etc/hosts</em></p>
  <pre><code>127.0.0.1    app.localhost
  127.0.0.1    static.localhost
  </code></pre>