Not able to connect to docker image with a spring boot application

Your application seems fine, and it seems you can access it from within the container with localhost as per your comment:

root@a6664e1d3b83:/# curl localhost:8085/rest/docker/hello1 
Greetings
root@a6664e1d3b83:/# . I am able to get the response from the curl url 

It's probably because Spring Boot will bind to localhost by default (127.0.0.1). You need to add the following properties to bind to all host (or specify which IP on which to bind):

server.address=0.0.0.0 # Bind all

In your application.properties

See this post and the Spring Boot Common Properties


The URLs I was trying was localhost , 127.0.0.1 , 0.0.0.0, etc .

The application worked once I ran the docker host URL:

http://192.168.99.100:8085/rest/docker/hello1