简体   繁体   中英

add external application.properties file to a dockerized spring boot web app inside tomcat

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

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

您可以尝试按照配置应用程序类路径的方式来引用docker容器将作为卷装入的路径或绑定到主机文件系统并将配置文件放在那里。

--spring.config.location=file:/config/application.properties

可能可能放在您在启动docker镜像的文件中指定的JAVA_OPTS环境变量中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM