【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

最新文章

  1. Leetcode 230. Kth Smallest Element in a BST
  2. LoadRunner监控Linux
  3. VMware系统运维(五)安装SSO vCenter Single Sign-On
  4. POJ1365 - Prime Land(质因数分解)
  5. 搭建mongodb分片
  6. 关于java IO 过程当中同时读写的问题
  7. 自定义JsonResult处理JSON序列化DateTime类型数据(Ext4.2+ASP.NET MVC 4)
  8. CSS文字样式
  9. Oracle多实例的配置方法
  10. 学习React系列(一)——React.Component 生命周期
  11. STL::sort函数实现
  12. mybatis之批量插入
  13. 【转】Python之函数进阶
  14. Spring Boot + thymeleaf 后台与页面(二)
  15. ajax 拼接html标签 thinkphp
  16. HDU 1698 Just a Hook (线段树区间更新入门题)
  17. 【2017 4 24 - B】 组合数
  18. HDOJ 5288 OO’s Sequence 水
  19. JS修改当前控件样式&为控件追加事件
  20. windows tomcat nginx session(当一台tomcat关闭后)

热门文章

  1. 在C语言中如何嵌入python脚本
  2. Luogu 2597 [ZJOI2012]灾难
  3. bootstrap图片切换效果
  4. libtool: syntax error near unexpected token `]*
  5. [原创]Java源代码学习
  6. 用css画的一个图形 空心正方形+四边四色
  7. (原创)数据结构之利用KMP算法解决串的模式匹配问题
  8. Windowns DOS For 循环实例
  9. 【noip2017】【Luogu3960】列队 线段树
  10. loj #6226. 「网络流 24 题」骑士共存问题