2

I have following in my Dockerfile for a simple spring boot rest service project:

FROM openjdk:8

EXPOSE 8080

ADD /target/spotdemo-0.0.1-SNAPSHOT.jar spotdemo.jar

ENTRYPOINT ["java", "-jar", "spotdemo.jar"]

Image is build successfully, and I can launch container for it too:

docker run -p 8080:8080 -t spotdemo-microservice

..........

Started SpotDemoApplication in 3.256 seconds (JVM running for 4.005)

But trying to access endpoint from postman throws error:

{
"timestamp": "2020-04-15T15:08:43.218+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/hello"
}

What else I am supposed to do here?

Edit:

Controller is as:

@RestController
public class TestController {

  @GetMapping("/hello")
  public String hello() {
    return "Hello World";
  }
}

Call is as:

http://localhost:8080/hello

Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • hä? Are you actually handling the `/hello` endpoint? Show us the code of the controller as well for proper help. And what is the exact request you're sending (method and URL)? – Florian Apr 15 '20 at 15:13

1 Answers1

2

Probably a duplication of this.

But seems the answer is:

add server.address=0.0.0.0 to application.properties

Lucas Campos
  • 1,860
  • 11
  • 17