简体   繁体   English

将外部application.properties文件添加到tomcat内的dockerized spring boot web app

[英]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.

相关问题 Spring Boot应用程序不拉入外部application.properties文件 - Spring boot application not pulling external application.properties file in Dockerized Spring Boot 应用程序不使用挂载的 Kubernetes ConfigMap (application.properties) - Dockerized Spring Boot app not using mounted Kubernetes ConfigMap (application.properties) 使用特定的application.properties文件将Spring Boot应用程序部署到Heroku - Deploy Spring Boot app to Heroku with a particular application.properties file 在插件中通过Tomcat覆盖Spring Boot application.properties属性? - Overwriting Spring Boot application.properties properties in plugin and through Tomcat? Spring 引导无法识别 application.properties 文件 - Spring Boot not recognizing application.properties file 使用外部属性覆盖 spring-boot application.properties - Override spring-boot application.properties with external properties 如何在Spring Boot中的application.properties中指定外部属性文件? - How to specify external properties files in application.properties in Spring Boot? 如何在Spring Boot中将application.properties外部化到外部文件系统位置? - How to externalize application.properties to an external filesystem location in Spring Boot? Spring 引导类路径配置文件覆盖外部 application.properties - Spring boot classpath configuration files overrides external application.properties 在jar spring boot外部目录中搜索application.properties - Search application.properties in directory external to jar spring boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM