title: Make a request to a spring api running in a docker container from windows host
body: <p>So, I searched around for an answer on this matter but either people don't address the issue or they say there's no problem doing this on their computer (mac or linux). It seems like this might be a windows problem.</p>
  <p>I have a spring api running on a docker container (linux container). I use docker desktop on windows and I'm trying to make a request (in insomnia/postman/wtv) to that api.</p>
  <p>If I run the api locally making the following request works perfectly:</p>
  <pre><code>http://localhost:8080/api/task/
  </code></pre>
  <p>This will list multiples task elements.</p>
  <p>I've containerized this application like so:</p>
  <p><strong>Dockerfile</strong></p>
  <pre><code>FROM openjdk:11.0.7
  COPY ./target/spring-api-0.0.1-SNAPSHOT.jar /usr/app/
  WORKDIR /usr/app
  RUN sh -c 'touch spring-api-0.0.1-SNAPSHOT.jar'
  ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;spring-api-0.0.1-SNAPSHOT.jar&quot;]
  </code></pre>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: '3.8'
  services:
    api:
      build: .
      depends_on:
        - mysql
      environment:
        - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/test?createDatabaseIfNotExist=true
      ports:
        - &quot;8080:80&quot;
  
    mysql:
      image: mysql
      ports:
        - &quot;3306:3306&quot;
      environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=root
      - MYSQL_PASSWORD=root
      - MYSQL_DATABASE=test
  </code></pre>
  <p>If I do docker-compose up this works without issue:</p>
  <p><a href="https://i.stack.imgur.com/OdRWU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OdRWU.png" alt="Spring app running on a docker container" /></a></p>
  <p>The problem is, if I try to call the same endpoint as before from localhost I don't get any response.
  Insomnia returns an error saying: Error: Server returned nothing (no headers, no data)</p>
  <p>I've also tried connecting to the container's ip (got it from docker inspect) but no luck.</p>
  <p>Ports are exposed in docker-compose.yml. What am I missing?</p>
  <p>Thanks in advance.</p>