[英]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. 我有tomcat的docker镜像和tomcat / webapps文件夹中的spring boot web应用程序。 The app has its own application.properties file packed in the folder. 该应用程序有自己的application.properties文件打包在该文件夹中。 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. 我想为运行docker镜像的任何人提供选项来安装它自己的外部application.properties文件 ,以便运行spring boot web app。
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 类似于agnul的答案,你可以从docker引擎的主机上安装一个卷,请看这里
Something like: 就像是:
docker run -d -P --name web -v /config:/config ...
When you start your JVM you give the system property to /config 启动JVM时,将系统属性提供给/ config
java -jar myproject.jar --spring.config.location=file:/config/application.properties
您可以尝试按照配置应用程序类路径的方式来引用docker容器将作为卷装入的路径或绑定到主机文件系统并将配置文件放在那里。
--spring.config.location=file:/config/application.properties
可能可能放在您在启动docker镜像的文件中指定的JAVA_OPTS
环境变量中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.