您现在的位置是:热点 >>正文
云计算核心技术Docker教程:Docker在容器中运行多个服务
热点1908人已围观
简介...
容器的主要运行过程是ENTRYPOINT和或CMD末尾Dockerfile。通常建议您通过每个容器使用一项服务来分离关注区域。该服务可以分叉到多个进程中(例如,Apache Web服务器启动云计多个工作进程)。可以有多个进程,但是要从Docker中获得最大收益,请避免一个容器负责整个应用程序的多个方面。您可以使用用户定义的网络和共享卷连接多个容器。
容器的主要过程负责管理它启动的所有过程算核。在某些情况下,主流程设计不当,并且在容器退出时无法优雅地处理“收获”(停止)子流程。如果您的进程属于此类别,则可以--init在运行容器时使用该选项。该--init标志将一个微小的init进心技程作为主要进程插入到容器中,并在容器退出时处理所有进程的收割。用这种方式处理此类过程优于使用成熟的初始化过程(如sysvinit,upstart)或systemd处理容器中的过程生命周期。
如果您需术D要在一个容器中运行多个服务,则可以通过几种不同的方式来完成此操作。
将所有命令放入包装器脚本中,其中包含测试和调试信息。以您的身份运行包装脚本CMD。这是一个非常幼稚的例子。首先,包装脚本:
接oc下来,Dockerfile:
FROM ubuntu:latest
COPY my_first_process my_first_process
COPY my_second_process my_second_pkerocess
COPY my_wrapper_script.sh my_wrapper_script.sh
CMD ./my_wrapper_script.sh
如果您有一个需要首先启动并保持运行的主要r教流程,但是您暂时需要运行其他一些流程(可能与该主要流程进行交互),则可以使用bash的作业控制来简化这一过程。首先,包装脚本:
FROM ubuntu:latest
COPY my_main_proce程:ss my_main_process
COPY my_helper_process my_helper_process
COPY my_wrapper_script.sh my_wrapper_scripDot.sh
CMD ./my_wrapper_script.sh
使用类似的流程管理器supervisord。这是一种中等重量的方法,需要您将supervisord映像及其配置打包(或将映像基于包括在内ck的映像supervisord)及其管理的不同应用程序一起打包。然后,您将启动supervisord,它会为您管理流程。下面是使用这种方法,它假定预先编写的一个例子Dockerfile superervisord.conf,my_first_process和my_second_process文件都存在于相同的目录中Dockerfile。
FROM ubuntu:latest
RUN apt-在容get update && apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/器中supervisor/conf.d/supervisord.conf
COPY my_first_process my_first_process
COPY my_second_process my_s运行econd_process
CMD ["/usr/bin/supervisord"]
Tags:
相关文章
标签: xAI Grok 4.1 LMArena
热点云梦级11月18日云梦级消息,埃隆・马斯克(Elon Musk)旗下的人工智能公司 xAI 11 月 17 日宣布推出最新大语言模型 Grok 4.1,并已面向所有用户全面推送。 本次更新旨在全面提升...
【热点】
阅读更多IBM首席执行官表示,量子计算有望在2023年进入市场
热点对于许多人来说,量子计算仍然是科幻小说的流行语。但是据IBM首席执行官Arvind Krishna称,他的公司的客户最早可以在2023年使用该技术,并获得丰厚的收益。 克里希纳在今天的《财富头脑风暴技...
【热点】
阅读更多美国参议员提出“SANDBOX 法案” 允许AI公司设定长达10年自我监管规则
热点近日,美国参议员特德・克鲁兹(Ted Cruz)提出了一项名为 “SANDBOX 法案” 的新立法。这项法案旨在为人工智能(AI)公司提供一个 “监管沙箱”,让它们在较少的联邦监管下进行实验。 图源备...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.manga-news.com/index.php/recherche/?q=谷歌搜索留痕霸屏【tg:seogoogle987】,oJg
- https://wwwcp.umes.edu/search/谷歌搜索留痕霸屏【tg:seogoogle987】,oTK
- https://www.pacific-lifestyle.co.uk/search?sort=alphabetical&term=谷歌搜索留痕霸屏【tg:seogoogle987】,Wxx
- https://www.lauben.com/de/?s=谷歌搜索留痕霸屏【tg:seogoogle987】,YCs
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌搜索留痕霸屏【tg:seogoogle987】Xb6
- https://www.vocabulary.com/dictionary/谷歌搜索留痕霸屏【tg:seogoogle987】,Ch7
- https://www.thealexandrian.net/?s=谷歌搜索留痕霸屏【tg:seogoogle987】,IDg
- https://www.zalora.sg/catalog/?cat=112&q=谷歌搜索留痕霸屏【tg:seogoogle987】,Qlh
- https://www.woorden.org/spreekwoord.php?woord=谷歌搜索留痕霸屏【tg:seogoogle987】,V1G
- https://search.danawa.com/dsearch.php?query=谷歌搜索留痕霸屏【tg:seogoogle987】EZf
- https://www.randjleather.co.uk/index.php?route=product/search&tag=谷歌搜索留痕霸屏【tg:seogoogle987】,ol6
- https://www.lneg.pt/en/?s=谷歌搜索留痕霸屏【tg:seogoogle987】,qKw
- https://www.roberthalf.com/us/en/jobs/all/谷歌搜索留痕霸屏【tg:seogoogle987】jnr
- https://www.teamlab.art/it/?submit=谷歌搜索留痕霸屏【tg:seogoogle987】,fXv
- https://www.lneg.pt/?cat=140&s=谷歌搜索留痕霸屏【tg:seogoogle987】,uGy
- https://www.searcychamber.com/list/search?AsfnA=DtkTQzs&q=谷歌搜索留痕霸屏【tg:seogoogle987】,EYZ
- https://www.sensorshop24.de/catalogsearch/result/index/?type=132&q=谷歌搜索留痕霸屏【tg:seogoogle987】,Rw6
- https://www.ncetm.org.uk/search?action=CHECK&q=谷歌搜索留痕霸屏【tg:seogoogle987】,jcI
- https://m.shoppinghow.kakao.com/m/search/q/谷歌搜索留痕霸屏【tg:seogoogle987】mMU
- https://www.pinkpanda.ro/magazin/ingrijirea-tenului?page=87&q=谷歌搜索留痕霸屏【tg:seogoogle987】,iVl
- https://www.posten-portal.de/search?query=谷歌搜索留痕霸屏【tg:seogoogle987】,xn8
- https://www.lifesciencesweden.se/search?q=谷歌搜索留痕霸屏【tg:seogoogle987】,UxU
- https://www.wattpad.com/search/谷歌搜索留痕霸屏【tg:seogoogle987】eAU
- https://www.kelsa.co.uk/catalogsearch/result/index/?T=1686132119291&q=谷歌搜索留痕霸屏【tg:seogoogle987】,pJS
- https://xehay.vn/tim-kiem/=谷歌搜索留痕霸屏【tg:seogoogle987】,WCH
- https://www.nbm.org/?action=QUERY&s=谷歌搜索留痕霸屏【tg:seogoogle987】,rWe
- https://www.remit.co.jp/en/?s=谷歌搜索留痕霸屏【tg:seogoogle987】,8z0
- https://www.tarleton.edu/news/search/谷歌搜索留痕霸屏【tg:seogoogle987】,hyJ
- https://www.remit.co.jp/vi/?s=谷歌搜索留痕霸屏【tg:seogoogle987】v7V
- https://www.swecobelgium.be/?page=9&s=谷歌搜索留痕霸屏【tg:seogoogle987】,Pp9
- https://www.sic-info.org/?s=谷歌搜索留痕霸屏【tg:seogoogle987】,vT5
- https://www.merchbar.com/search?q=谷歌搜索留痕霸屏【tg:seogoogle987】,oyp
- https://www.youm7.com/Home/Search?allwords=谷歌搜索留痕霸屏【tg:seogoogle987】,pgV
- https://www.temu.com/search_result.html?search_key=谷歌搜索留痕霸屏【tg:seogoogle987】jaW
- https://www.olx.ba/pretraga?trazilica=谷歌搜索留痕霸屏【tg:seogoogle987】,GuO
- https://www.ussalabama.com/?action=CHECK&s=谷歌搜索留痕霸屏【tg:seogoogle987】,PeK
- https://www.shacknews.com/editorial-search?q=谷歌搜索留痕霸屏【tg:seogoogle987】,JmH
- https://www.pearlstonecenter.org/search/谷歌搜索留痕霸屏【tg:seogoogle987】,Sp2
- https://www.maine.gov/pfr/professionallicensing/search/node?keys=谷歌搜索留痕霸屏【tg:seogoogle987】,MlV
- https://www.prattlibrary.org/search?q=谷歌搜索留痕霸屏【tg:seogoogle987】,tD5
- https://www.goodreads.com/quotes/tag/谷歌搜索留痕霸屏【tg:seogoogle987】v1v
- https://www.ntv.co.jp/3min/search/?action=QUERY&q=谷歌搜索留痕霸屏【tg:seogoogle987】,scO
- https://www.welshmountainzoo.org/shop/index.php?routeproduct/search&tag=谷歌搜索留痕霸屏【tg:seogoogle987】,q98
- https://dict.naver.com/dict.search?dicQuery&query=谷歌搜索留痕霸屏【tg:seogoogle987】iL8
- https://www.mingwai.edu.hk/?langzh-hant&s=谷歌搜索留痕霸屏【tg:seogoogle987】,fx8
- https://www.ucycle.com/search/=谷歌搜索留痕霸屏【tg:seogoogle987】,Xwr
- https://www.usslexington.com/?action=QUERY&s=谷歌搜索留痕霸屏【tg:seogoogle987】,syz
- https://www.valuecolleges.com/?action=QUERY&s=谷歌搜索留痕霸屏【tg:seogoogle987】,fGt
- https://m.shoppinghow.kakao.com/m/search/q/谷歌搜索留痕霸屏【tg:seogoogle987】CyN
- https://www.rhymezone.com/r/rhyme.cgi?typeofrhyme=oldrel&loc=nojs&Word=谷歌搜索留痕霸屏【tg:seogoogle987】,oIK