dockerintellij-ideacontainersportintellij-plugin

Spring Boot app works in Docker CLI/Desktop but not when run inside IntelliJ – not accepting requests


I'm working on a Spring Boot application that runs fine when I:

Run it directly (without Docker)

Dockerize it and run it via Docker CLI: docker run -p 8080:8080 my-app

Run it through Docker Desktop

However, when I run the container inside IntelliJ IDEA (using the Docker integration), the app starts up without errors, but it's not accepting any HTTP requests on localhost:8080. I suspect it's a port binding issue, but I’m not sure how to configure it properly in IntelliJ.

Things I’ve checked:

The container is running inside IntelliJ

Port 8080 is exposed in the Dockerfile (EXPOSE 8080)

The application runs fine otherwise

No firewall issues on my machine

The app is listening on 0.0.0.0:8080

Is there something specific I need to configure in IntelliJ to make sure the container's port is accessible on my host?

Any help is appreciated!


Solution

  • EXPOSE 8080 instruction in your Dockerfile is just metadata and used for documentation, it doesn't actually publish the port to your host machine. When you use docker run -p 8080:8080 you're explicitly telling Docker to map the host's port 8080 to the container's port 8080. So you need to set this mapping in your IntelliJ. Set the port bindings for host and container port in your Docker section in Edit Configuration :

    enter image description here