title: Can't access spring boot app running inside docker container from localhost
body: <p>I've been struggling for a couple of hours on this issue.
  I have the following setup:</p>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM openjdk:8-jdk-alpine
  ARG JAR_FILE=target/ROOT.jar
  COPY ${JAR_FILE} app.jar
  ENTRYPOINT ["java","-jar","app.jar","--spring.profiles.active=dev"]
  EXPOSE 8080
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '3'
  services:
    app:
        container_name: app
        build:
           context: .
           dockerfile: Dockerfile
        restart: always
        links:
          - mysql-db
        depends_on:
          - mysql-db
        ports:
          - 8080:8080
        expose:
          - 8080
        networks:
          - spring-network
    mysql-db:
        restart: always
        container_name: mysql_db
        image: "mysql:8.0.19" 
        ports:
          - 3306:3306
        networks:
          - spring-network
        environment:
           MYSQL_ROOT_PASSWORD: 'password'
           MYSQL_DATABASE: 'db'
           MYSQL_USER: 'db-user'
           MYSQL_PASSWORD: 'password'
        volumes:
          - mysql-db:/var/lib/mysql
        command: --innodb-use-native-aio=0
        security_opt:
          - seccomp:unconfined
  volumes:
    mysql-db:
  networks:
      spring-network:
          driver: bridge
  </code></pre>
  
  <p>when I run the app using <code>docker-compose up</code> it works fine inside the container, but when I hit localhost:8080 on the browser I got </p>
  
  <blockquote>
    <p>localhost unexpectedly closed the connection</p>
  </blockquote>
  
  <p>Edit: </p>
  
  <ul>
  <li>spring boot app running on port 8080</li>
  <li>docker version 19.03.8</li>
  </ul>