title: Docker-compose: Docker containers can't connect using service names
body: <p>I have 3 containers. One is a lighttpd server serving static content (<strong>front</strong>). I have 2 flask servers handling the backend (<strong>back</strong> and <strong>model</strong>)</p>
  
  <p>This is my docker-compose.yml</p>
  
  <pre><code>version: "3"
  services:
    front:
      image: ecd3:latest
      ports:
        - 4200:80
      tty: true
      links:
        - "back"
      depends_on:
        - back
      networks:
        - mynet
  
    back:
      image: esd3:latest
      ports:
        - 5000:5000
      links:
        - "model"
      depends_on:
        - model
      networks:
        - mynet
  
    model:
      image: mok:latest
      ports:
        - 5001:5001
      networks:
        - mynet
  
  networks:
    mynet:
  </code></pre>
  
  <p>I'm trying to send an http request to my flask server (<strong>back</strong>) from my frontend (<strong>front</strong>). I have bound the flask server to 0.0.0.0 and even used the service name in the frontend (<a href="http://back:5000/endpoint" rel="nofollow noreferrer">http://back:5000/endpoint</a>)</p>
  
  <p>Trying to curl the flask server inside the frontend container (<em>curl back:5000</em>) gives me this:</p>
  
  <pre><code>curl: (52) Empty reply from server
  </code></pre>
  
  <p>Pinging the flask server from inside the frontend container works. This means that the connection must have been established.</p>
  
  <p>Why can't I connect to my flask server from my frontend?</p>