How do I access a spring app running in a docker container?

The typical issue that occurs when dockerizing a web service (here, a Java Spring Boot application) is that the localhost address shouldn’t be used and replaced with 0.0.0.0.

For more details, see this SO answer that explains well what represents localhost in the context of Docker.

Regarding the 0.0.0.0 address, this special IP just means here “any IPv4 address”.

Finally as the OP confirmed in a comment, for Spring Boot it suffices to assign the server.address property in the application.properties file to achieve this (cf. documentation).

Leave a Comment