Spring Boot can't read application.properties in Docker
You have to add the application.properties file in the docker /app/ directory. Ur docker directory structure will be
app -main.jar -application.properties
You can do so by using ADD /ur/local/location/application.properties /app/application.properties
Then better write this command in your docker file
ENTRYPOINT ["java" ,"-Djava.security.egd=file:/dev/./urandom --spring.config.location=classpath:file:/app/application-properties","-jar","/app/main.jar"]
Your whole dockerFile should look like this:
FROM java:8-jreVOLUME /tmpCOPY ./mail.jar /app/mail.jarADD /ur/local/location/application.properties /app/application.propertiesENTRYPOINT ["java" ,"-Djava.security.egd=file:/dev/./urandom --spring.config.location=classpath:file:/app/application-properties","-jar","/app/main.jar"]EXPOSE 8080
Rename Application.yml to application.yml. It's with reference to the name used in the comments as Application.yml.
Application.yml works well with widows but breaks inside linux containers.
For the context path, you have to add the context path in the properties file.inside the application-default.properties:
server.servlet.contextPath=/myContext
Then build your project,
mvn clean install
Then create a docker image and run that image.