Prometheus之Dockerfile编写镜像构建容器启
从官方镜像启动:promprometheus
拉取镜像dockerpullpromprometheus
启动容器
方式1:dockerruntdp9090:9090nameprometheus1promprometheus
方式2:路径挂载dockerrunp9090:9090vpathtoprometheus。yml:etcprometheusprometheus。ymlpromprometheusdockerrunp9090:9090vpathtoconfig:etcprometheuspromprometheus官方Dockerfile分析
官方Dockerfile文件如下ARGARCHamd64ARGOSlinuxFROMquay。ioprometheusbusybox{OS}{ARCH}:latestLABELmaintainerThePrometheusAuthorsprometheusdevelopersgooglegroups。comARGARCHamd64ARGOSlinuxCOPY。build{OS}{ARCH}prometheusbinprometheusCOPY。build{OS}{ARCH}promtoolbinpromtoolCOPYdocumentationexamplesprometheus。ymletcprometheusprometheus。ymlCOPYconsolelibrariesusrshareprometheusconsolelibrariesCOPYconsolesusrshareprometheusconsolesCOPYLICENSELICENSECOPYNOTICENOTICECOPYnpmlicenses。tar。bz2npmlicenses。tar。bz2WORKDIRprometheusRUNlnsusrshareprometheusconsolelibrariesusrshareprometheusconsolesetcprometheuschownRnobody:nobodyetcprometheusprometheusUSERnobodyEXPOSE9090VOLUME〔prometheus〕ENTRYPOINT〔binprometheus〕CMD〔config。fileetcprometheusprometheus。yml,storage。tsdb。pathprometheus,web。console。librariesusrshareprometheusconsolelibraries,web。console。templatesusrshareprometheusconsoles〕
从官网Dockerfile文件可知:使用busybox作为基础镜像拷贝相关文件(prometheus、promtool、prometheus。yml等)到指定目录(bin、etc)指定工作目录prometheus容器内端口9090指定默认匿名卷为prometheus,Prometheus运行产生的数据将写到宿主机相关目录ENTRYPOINT容器启动入口点为binprometheusCMD指定容器启动参数为:config。fileetcprometheusprometheus。yml,storage。tsdb。pathprometheus,web。console。librariesusrshareprometheusconsolelibraries,web。console。templatesusrshareprometheusconsoles
容器内Prometheus启动命令为:binprometheusconfig。fileetcprometheusprometheus。ymlstorage。tsdb。pathprometheusweb。console。librariesusrshareprometheusconsolelibrariesweb。console。templatesusrshareprometheusconsoles
进入容器查看Prometheus的进程:〔rootdocker〕dockerexecitprometheus1shprometheusprometheuspsefgrepprometheu〔s〕1nobody0:53binprometheusconfig。fileetcprometheusprometheus。ymlstorage。tsdb。pathprometheusweb。console。librariesusrshareprometheusconsolelibrariesweb。console。templatesusrshareprometheusconsoles编写自己的Dockerfile
这里编写自己的Dockerfile进行构建,开启Prometheus进程的配置热加载和数据库管理功能。FROMamd64busybox:1。35LABELmaintainerThePrometheusAuthorswuenwuenARGARCHamd64ARGOSlinuxCOPYprometheus。{OS}{ARCH}prometheusprometheusbinCOPYprometheus。{OS}{ARCH}promtoolprometheusbinCOPYprometheus。{OS}{ARCH}prometheus。ymlprometheusetcprometheus。ymlCOPYprometheus。{OS}{ARCH}consolelibrariesprometheusconsolelibrariesCOPYprometheus。{OS}{ARCH}consolesprometheusconsolesCOPYprometheus。{OS}{ARCH}LICENSEprometheusLICENSECOPYprometheus。{OS}{ARCH}NOTICEprometheusNOTICEWORKDIRprometheusRUNlnsprometheusbinprometheusprometheusbinpromtoolbinchownRroot:rootprometheusUSERrootEXPOSE9090VOLUME〔prometheusdata,prometheusetc〕ENTRYPOINT〔binprometheus〕CMD〔config。fileprometheusetcprometheus。yml,storage。tsdb。pathprometheusdata,web。console。librariesprometheusconsolelibraries,web。console。templatesprometheusconsoles,web。enablelifecycle,web。enableadminapi〕
解读:使用amd64busybox:1。35作为基础镜像,将Prometheus的二进制文件放入bin目录,将配置文件统一放入etc目录;将配置文件目录和数据存储目录定义为匿名卷;启动方式中,新增两项配置,开启配置文件的热加载和数据库管理功能。
在同目录下添加一个。dockerignore文件,来屏蔽一些无关构建的文件:prometheus。linuxamd64。tar。gzetc构建镜像:
新建目录,将版本包和Dockerfile文件放入该目录mkdirrootprometheus;cdrootprometheuslsDockerfileprometheus2。33。1。linuxamd64。tar。gz
解压版本包,同时新建。dockerignore文件,在该文件下添加与构建无关的文件或目录(这表示构建时,不将这些文件复制到构建上下文环境中)tarzxfprometheus2。33。1。linuxamd64。tar。gzcat。dockerignoreprometheus。linuxamd64。tar。gz
执行构建命令dockerbuilddockerbuildtprometheus:v1。SendingbuildcontexttoDockerdaemon200。8MBStep118:FROMamd64busybox:1。3596b2896db672Step218:LABELmaintainerThePrometheusAuthorswuenwuenRunningin04e215d3c3e0Removingintermediatecontainer04e215d3c3e088050ed9e09dStep318:ARGARCHamd64Runningin5ce5d1b12e0fRemovingintermediatecontainer5ce5d1b12e0f370832a62c71Step418:ARGOSlinuxRunningind7ea847b2d90Removingintermediatecontainerd7ea847b2d90cf9781cb7722Step518:COPYprometheus。{OS}{ARCH}prometheusprometheusbin42b4b03f8332Step618:COPYprometheus。{OS}{ARCH}promtoolprometheusbin897066bd0ca3Step718:COPYprometheus。{OS}{ARCH}prometheus。ymlprometheusetcprometheus。ymlb141fa2c22a6Step818:COPYprometheus。{OS}{ARCH}consolelibrariesprometheusconsolelibraries228b62d5e860Step918:COPYprometheus。{OS}{ARCH}consolesprometheusconsoles5c9125f39322Step1018:COPYprometheus。{OS}{ARCH}LICENSEprometheusLICENSEc89f57bbceb6Step1118:COPYprometheus。{OS}{ARCH}NOTICEprometheusNOTICE7e459dfd86feStep1218:WORKDIRprometheusRunningin8f09cea3e03eRemovingintermediatecontainer8f09cea3e03eee1f386d159bStep1318:RUNlnsprometheusbinprometheusprometheusbinpromtoolbinchownRroot:rootprometheusRunningin093e9b6b8d14Removingintermediatecontainer093e9b6b8d14121df7a93221Step1418:USERrootRunninginb4ffed0d491aRemovingintermediatecontainerb4ffed0d491a75e2aada4653Step1518:EXPOSE9090Runninginb09e22947d56Removingintermediatecontainerb09e22947d56c700606bd44dStep1618:VOLUME〔prometheusdata,prometheusetc〕Runningine18dd4f3af2aRemovingintermediatecontainere18dd4f3af2a824d398febddStep1718:ENTRYPOINT〔binprometheus〕Runninginff8fb122f2fbRemovingintermediatecontainerff8fb122f2fb414d2523bb9bStep1818:CMD〔config。fileprometheusetcprometheus。yml,storage。tsdb。pathprometheusdata,web。console。librariesprometheusconsolelibraries,web。console。templatesprometheusconsoles,web。enablelifecycle,web。enableadminapi〕Runningin56a8542d31a9Removingintermediatecontainer56a8542d31a917f5fa014281Successfullybuilt17f5fa014281Successfullytaggedprometheus:v1
查看构建的镜像:dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZEprometheusv117f5fa0142816minutesago403MBamd64busybox1。3596b2896db6722weeksago1。24MBpromprometheuslatesta3d385fc29f92monthsago201MB可以看到自己构建的镜像比官方镜像大了一倍启动容器:
直接启动:dockerruntdprometheus:v1dockerruntdp9090:9090prometheus:v1
直接启动后,配置文件和数据存储目录将默认使用匿名挂载。
挂载路径使用dockerinspect命令查看
路径挂载(推荐):
选择挂载出配置文件目录,数据存储目录使用默认的匿名挂载就行了。
由于路径挂载时,容器内挂载路径下的文件会被隐藏,同时Prometheus的启动又需要指定配置文件,所以启动容器前,需要提前将配置文件放在挂载点路径下,以避免容器启动后Prometheus进程无法启动,导致容器退出。
新建挂载点,并存放配置文件:treerootprometheusetcrootprometheusetcfirstrules。ymlprometheus。ymlstaticconfignodeexporter。yml
然后就可以使用构建的镜像来启动容器了,命令如下选择其中一个即可dockertdvrootprometheusetc:prometheusetcprometheus:v1dockerruntdp9090:9090nameprometheus1vrootprometheusetc:prometheusetcprometheus:v1dockerruntdp9090:9090nameprometheus1vrootprometheusetc:prometheusetcprometheus:v1
查看容器:dockerpsCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESb2ebd62251acprometheus:v1binprometheuscAboutaminuteagoUpAboutaminute0。0。0。0:90909090tcp,:::90909090tcpprometheus1dockerpsformattable{{。Image}}{{。ID}}{{。Ports}}{{。Status}}{{。Names}}IMAGECONTAINERIDPORTSSTATUSNAMESprometheus:v1b2ebd62251ac0。0。0。0:90909090tcp,:::90909090tcpUp6minutesprometheus1
访问Prometheus的UI界面:http:192。168。175。130:9090
原文地址https:www。cnblogs。comMrRebootp15937802。html
人生过半,一切看淡文飞鱼01hr有一句话说,心无增减,得失随缘。人生,其实很多东西都是冥冥之中注定好的,是你的,就是你的,不是你的,强求也没有用。人的命,天注定。命中有时终须有,命中无时莫强求。年少
心之所向,素履往之今天是十二月第一天。天气很冷,下午,还飘起了雪花,在瑟瑟发抖中倔强地彰显出浪漫。11月日子悄无声息地过去了,感觉很忙也很烦。回头看去,却找不出值得赞扬的事情。月初制定的计划总是那么
一年又一年,愿君且珍重流水时光,总是匆匆一晃。惊鸿一瞥间,天寒雾几重,雪落人何在?一路上,多少人曾走过你眉间,走进你心房,在细水长流的日子里,擦出细碎的芬芳?又有多少人,曾许你扬鞭纵马走四方,却无奈地转
你这一辈子,有没有为五毛钱拼过命?微信里很久没联系的朋友突然找你,基本上跑不出三件事婚礼邀请朋友圈点赞拉票和拼多多砍价。而现在,又要加上一件淘宝双十一盖楼。因为发拼多多砍一刀链接让我砍价,我已经退出了3个家族群,拉
阿里巴巴的双轨制阿里巴巴的双轨制双轨制来源于通用电气。当年关明生来到了阿里巴巴之后,就带来了通用电气的这套管理方法。阿里巴巴是在2000年年底开始应用这套PM序列机制的,而在中国落实这套管理方法最
机会来了!布伦森的出色表现,将助湖人得到罗斯10号秀?据Heavy记者SeanDeveney报道,罗斯可能不会很想离开尼克斯但他也想出场打球和赢球。此外,消息源透露,湖人一直对罗斯有意。从这则消息我们可以得出两点第一,罗斯有离开尼克斯
整容老去和优雅老去有啥区别?看完你就清楚如何选择了通过现代的无数事实,可以证明颜值就是踏进娱乐圈最好用的敲门砖,我们知道有些地方表演团队是非常多的,他们经常会四处挖人。首先挖到的都是一些颜值逆天的人,如果颜值非常高,很有可能就会被
卡塔尔世界杯瑞士队32逆转塞尔维亚队晋级16强新华社多哈12月2日电(记者张逸飞董意行肖亚卓)2日,卡塔尔世界杯小组赛G组迎来最后一轮较量,瑞士队上演逆转好戏以32战胜塞尔维亚队,与巴西队携手晋级16强。12月2日,塞尔维亚队
内线能防外线能投,和后卫适配,替阿联上场,广东队的春天又来了关于汉密尔顿和广东队签约的消息,很多球迷都知晓了,但是仍然有一部分球迷不理解,在这个阶段广东队为什么要签下这位北京队的前外援呢?就着这个话题,咱们就展开聊一聊。首先,广东队内线的孱
小朱婷吴梦洁在排超的表现,挺让人失望,比李盈莹真的差太远中国排球超级联赛第一阶段的比赛已经有部分球队打完了,因为疫情原因,部分球队还有六场比赛暂时延后,目前已经结束第一阶段的球队里,上海光明优倍女排11胜2负,江苏中天钢铁女排10胜3负
她去山上摘桑椹,竟然在一颗桑树下捡到一枚金手镯都说胖人有福,看来你还真是个有福之人,竟然还能捡到一个足金手镯,虽然一万五六千不算多,但也算是一笔小财,金店老板对站在眼前胖胖的妇女说道胖胖的妇女姓王,都叫她王姐,由于过度肥胖,早