ENTRYPOINT .... - adds (ENTRYPOINT) the configuration for running our jar file.
I'd like to pay your attention on the following Entrypoint's parameter: -Dspring.data.mongodb.uri=mongodb://spring-demo-mongo/users. This parameter specifies URI for MongoDB. So, we can create different images for different environment, e.g. for QA and PROD with different URI.
And also spring-demo-mongo should be the same as named our MongoDB container.

Dockerfile could be placed at any folder. For demo purpose we've placed Dockerfile into springboot-mongo-demo/docker/ folder of our project.

Build Java project

We are almost ready to build our image, but first we need to build our Java project and place the jar file into the springboot-mongo-demo/docker folder of our project:

The command for running Spring Boot application inside docker looks very similar as for starting MongoDB container but with the following difference:-p 8080:8080 - publishes a container's port(s) to the host.