简体   繁体   English

Docker 卷在耳朵/jar/zip 内的文件上?

[英]Docker volume on a file inside an ear/jar/zip?

i encountered a problem where i have a properties file inside an ear that is dockerized and i want to change the variables of that file during run time,我遇到了一个问题,我在耳朵里有一个属性文件,它是 dockerized,我想在运行时更改该文件的变量,

So i was wondering is it possible to make a volume to that file (volume to a position that's inside a compressed file)?所以我想知道是否可以为该文件创建一个卷(压缩文件内的 position 的卷)?

And if no is there another solution?如果没有,还有其他解决方案吗?

If a value is supposed to change at runtime, in my opinion, it does not belong inside a.properties file, and it definitely does not belong inside your EAR.如果一个值应该在运行时更改,在我看来,它不属于 a.properties 文件,而且它绝对不属于您的 EAR。

Personally, I'd prefer to have something like that inside a database (if I have one at my disposal).就个人而言,我更喜欢在数据库中拥有类似的东西(如果我有一个可以使用的话)。 You could also have a "configuration server" which your application can call via REST, but that is probably overkill.您还可以有一个“配置服务器”,您的应用程序可以通过 REST 调用它,但这可能是矫枉过正。 If you absolutely need to have a properties file - use one that is outside of your EAR file, and use a regular volume.如果您绝对需要一个属性文件 - 使用一个在您的 EAR 文件之外的文件,并使用一个常规卷。 An EAR is supposed to be immutable and changing it at runtime will only bring you pain. EAR 应该是不可变的,在运行时更改它只会给您带来痛苦。

Not sure if thats possible.. You could try to do some docker exec -it bash and script your way to change the file.不确定这是否可能..您可以尝试执行一些docker exec -it bash并编写脚本来更改文件。 Or as the comments suggest rewrite your app to read properties from outside of ear from specified volume, which you can easily attach to your docker image或者正如评论建议重写您的应用程序以从指定音量的耳朵外部读取属性,您可以轻松地将其附加到您的 docker 图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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