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

后端 未结 1 1001
悲&欢浪女
悲&欢浪女 2020-12-02 01:32

I have the following for a docker file...

FROM openjdk:11-jdk-slim
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT [\"java\",\"-Dexternal.config         


        
相关标签:
1条回答
  • 2020-12-02 02:00

    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).

    0 讨论(0)
提交回复
热议问题