5
votes

I have a docker image of tomcat with my spring boot web app inside tomcat /webapps folder. The app has its own application.properties file packed in the folder. I want to give the option for anyone running the docker image to mount it's own external application.properties file for the spring boot web app to run by.

How can this by accomplished? thank you very much

3
Did you get a solution to this? I'm trying to do the same thing with a docker container . T - haju
@haju look at the comment of Essex Boy. should work - TommyW

3 Answers

5
votes

Similar answer to agnul, you can mount an volume from the docker engine's host, see here

Something like:

docker run -d -P --name web -v /config:/config ...

When you start your JVM you give the system property to /config

java -jar myproject.jar --spring.config.location=file:/config/application.properties
2
votes
--spring.config.location=file:/config/application.properties

could be possibly put to JAVA_OPTS environment variable you specify in file where you start the docker image.

1
votes

You could try something along the lines of configuring your application class path to reference a path that your docker container will mount as a volume or bind to the host file-system and put your configuration file there.