[转] 利用dockerize模板为容器内应用生成配置文件和环境变量
2024-09-02 05:28:51
【FROM】 https://blog.csdn.net/liucaihong123/article/details/51945413
首先试验一下dockerize的可用性:
最近一个docker容器里面的应用启动依赖于一个配置文件cfg.json
设置模板文件cfg.template.json格式如下:
{
"debug": true,
"hostname": {{ default .Env.HOSTNAME "\"\"" }},
"ip": {{ default .Env.IP "\"\"" }},
"plugin": {
"enabled": {{ default .Env.PLUGIN_ENABLED "false" }},
"dir": {{ default .Env.PLUGIN_DIR "\"./plugin\"" }},
"git": {{ default .Env.PLUGIN_GIT "\"https://github.com/open-falcon/plugin.git\"" }},
"logs": {{ default .Env.PLUGIN_LOGS "\"./logs\"" }}
}, }
在~/.bashrc中添加HOSTNAME,IP ,PLUGIN_ENABLED ,PLUGIN_DIR ,PLUGIN_GIT ,PLUGIN_LOGS 这几个环境变量,假如cfg.template.json在当前目录下,执行如下命令:
dockerize -template ./cfg.template.json:./cfg.json
就会按照模板文件生成cfg.json配置文件,注意:假如~/.bashrc中没有配置PLUGIN_GIT 环境变量,则会按照模板中的默认值"https://github.com/open-falcon/plugin.git"生成配置文件。
以下是生成的配置文件cfg.json:
{ "debug": true, "hostname": "node2",
"ip": "",
"plugin": {
"enabled": false,
"dir": "./plugin",
"git": "https://github.com/open-falcon/plugin.git",
"logs": "./logs"
},
}
测试成功。
以后在打包镜像的过程中,利用dockerize将模板中参数传到镜像中,具体用法参考文章:https://segmentfault.com/a/1190000000728440
转载请注明出处:http://blog.csdn.net/liucaihong123/article/details/51945413
最新文章
- Leetcode 230. Kth Smallest Element in a BST
- LoadRunner监控Linux
- VMware系统运维(五)安装SSO vCenter Single Sign-On
- POJ1365 - Prime Land(质因数分解)
- 搭建mongodb分片
- 关于java IO 过程当中同时读写的问题
- 自定义JsonResult处理JSON序列化DateTime类型数据(Ext4.2+ASP.NET MVC 4)
- CSS文字样式
- Oracle多实例的配置方法
- 学习React系列(一)——React.Component 生命周期
- STL::sort函数实现
- mybatis之批量插入
- 【转】Python之函数进阶
- Spring Boot + thymeleaf 后台与页面(二)
- ajax 拼接html标签 thinkphp
- HDU 1698 Just a Hook (线段树区间更新入门题)
- 【2017 4 24 - B】 组合数
- HDOJ 5288 OO’s Sequence 水
- JS修改当前控件样式&;为控件追加事件
- windows tomcat nginx session(当一台tomcat关闭后)
热门文章
- 在C语言中如何嵌入python脚本
- Luogu 2597 [ZJOI2012]灾难
- bootstrap图片切换效果
- libtool: syntax error near unexpected token `]*
- [原创]Java源代码学习
- 用css画的一个图形 空心正方形+四边四色
- (原创)数据结构之利用KMP算法解决串的模式匹配问题
- Windowns DOS For 循环实例
- 【noip2017】【Luogu3960】列队 线段树
- loj #6226. 「网络流 24 题」骑士共存问题