Reputation: 41
I have created a spring-boot application, when build and run it using maven it was working success full. But when i ran docker of my app it was running in the console but i can't access any REST endpoint browser is giving page not found error.
here is the content of my Dockerfile
FROM java:8
EXPOSE 5555:5555
ADD /hotline-api/target/hotline-api.jar hotline-api.jar
ENTRYPOINT ["java","-jar","hotline-api.jar","--spring.profiles.active=test"]
Upvotes: 4
Views: 4613
Reputation: 181
Try finding the docker machine port by using docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <containerNameOrId>
and then in place of localhost use the port that you get.
Upvotes: 0
Reputation: 563
Faced the same issue with docker setup on windows 7 using docker machine. The REST endpoint is mapped to the ip address of the docker machine. I solved it by getting the docker machine ip using:
docker-machine ip
Then use this to access the REST endpoints, like:
192.168.12.100:8080/login
Upvotes: 3
Reputation: 82
Make sure you have the jar at /hotline-api/target/hotline-api.jar
And also make sure that the latest jar is present by doing a gradle or maven build.
The jar won't be updated if you do a boot run which means your newly configured end point will not be present in the jar and hence not in the docker image
Upvotes: 0
Reputation: 11822
Add more parameter :
ENTRYPOINT ["java","-jar","hotline-api.jar","--spring.profiles.active=test","--server.port=5555"]
Then build container:
docker run -p 5555:5555 IMAGE_NAME
Upvotes: 0
Reputation: 15874
You also need to publish the port while running your image
docker run -p 5555:5555 IMAGE_NAME
Make sure you also expose the same port from your properties
file based on your profile (default/dev/test).
Upvotes: 6