您现在的位置是:热点 >>正文
云计算核心技术Docker教程:将Python的镜像作为容器运行
热点80269103人已围观
简介...
在上一个模块中,我们创建了示例应用程序,然后创建了一个用于生成映像的 Dockerfile。我们使用 docker 命令 docker build 创建了我们的镜像云计。现在我们有了一个图像,我们可以运行该图像并查看我们的应用程序是否正常运行。
容器是一个普通的操作系统进程,除了这个进程是隔离的,因为它有自己的文件系统,自己算核的网络,以及与主机分离的自己的隔离进程树。
要在容器内运行映像,我们使用该docker run命令。该docker run命令需要一个参数,即图像的名称。让我们启动我们心技的图像并确保它正确运行。在终端中运行以下命令。
$ docker run python-docker
运行此命令后,您会注意到您没有返回到命令提示符。这是因为我们的应术D用程序是一个 REST 服务器,并且在循环中运行,等待传入的请求,而不会将控制权返回给操作系统,直到我们停止容器。
让我们打开一个新终端,然后GET使用curl命令向服oc务器发出请求。
$ curl localhost:5000
curl: (7) Failed to connect to localhost port 5000: Connectionke refused
如您所见,我们的curl命令失败了,因为与我们的服务器的连接被拒绝。这意味着,我们无法在端口 5000 上连接到本地主机。这是意料之中的,因为我们r教的容器是独立运行的,包括网络。让我们停止容器并使用我们本地网络上发布的端口 5000 重新启动。
要停止容器,请按 ctrl-c。这将使您返回到终端提示。
要为我们程:的容器发布端口,我们将在命令中使用--publish flag(-p简称) docker run。--publish命令的格式为[host port]:[conta将Piner port]. 因此,如果我们想将容器内的端口 5000 暴露给容器外的端口 3000,我们将传递3000:5000给--publish标志。
我们在容器中运行 Flytask 应用程序时没有指定端口,默认是 5000。如果我们希望我们之前的请求在 5000 端口工作,我们可以将主机的 5000 端口映射到容器的 5000 端口:
$ dohocker run --publish 5000:5000 python-docker
现在,让我们从上面重新运行 curl 命令。记得打开一个新的终端。
$ curl locan的lhost:5000
Hello, Docker!
成功!我们能够通过端口 5000 连接到在容器内运行的应用程序。切换回运行容器的终端,您应该会看到 GET 请求记镜像录到控制台。
[31/Jan/2021 23:39:31] "GET / HTTP/1.1" 200 -
按 ctrl-c 停止容器。
Tags:
上一篇:我想吃火锅是什么梗
相关文章
谷歌云业务去年第四季度出现巨大运营亏损
热点新浪科技讯 2月3日早间消息,据报道,谷歌母公司Alphabet近日向外界表示,谷歌云业务在去年第四季度的运营中亏损12亿美元,这一数据很可能令华尔街的分析师们感到失望。 Alphabet在周二的一份...
【热点】
阅读更多云安全日报210416:思科RV系列路由器发现执行任意代码漏洞,需要尽快升级
热点4月15日,思科发布了安全公告,思科小型企业RV系列路由器发现执行任意代码漏洞,建议尽快升级。以下是漏洞详情: 漏洞详情 来源:https://tools.cisco.com/security/cen...
【热点】
阅读更多亚马逊多个网站出现用户宕机
热点新浪科技讯 北京时间6月24日上午消息 据宕机监控网站Downdetector称,周三晚些时候,亚马逊公司旗下的Alexa和Prime Video等平台有多名用户宕机。 Downdetector的数据...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.vet-direct.com/search?cat=72&term=必应蜘蛛池租用【tg:seogoogle987】,T04
- https://www.wellbees.com/index.php/catalogsearch/result/index/?q=必应蜘蛛池租用【tg:seogoogle987】,9Go
- https://www.teamlab.art/ko/?submit=必应蜘蛛池租用【tg:seogoogle987】,YVI
- https://www.teacherspayteachers.com/Browse/Search:必应蜘蛛池租用【tg:seogoogle987】,ERL
- https://www.maafushidive.com?collections?vendors?q=必应蜘蛛池租用【tg:seogoogle987】,y0K
- https://www.shopping.com/search.html?keyword=必应蜘蛛池租用【tg:seogoogle987】,xaE
- https://www.wikiart.org/pt/Search/必应蜘蛛池租用【tg:seogoogle987】,6vN
- https://www.rookwinkel.nl/catalogsearch/result/index/?q=必应蜘蛛池租用【tg:seogoogle987】,dLa
- https://www.wmfe.org/?s=必应蜘蛛池租用【tg:seogoogle987】,gA6
- https://nicolazzi.it/en/?s=必应蜘蛛池租用【tg:seogoogle987】,IMI
- https://www.theaerogroup.net/?cat=28&s=必应蜘蛛池租用【tg:seogoogle987】,rEx
- https://www.jusoen.com/addreng.asp?p1=必应蜘蛛池租用【tg:seogoogle987】KVm
- https://www.impactpool.org/search/?type=79&q=必应蜘蛛池租用【tg:seogoogle987】MBf
- https://wydden.com/?ID=r8w9WMSKWkOcmiaFWaUv0dzMdqZWfKtF&s=必应蜘蛛池租用【tg:seogoogle987】,IPS
- https://www.partilerdunyasi.com/index.php?route=product/search&tag=必应蜘蛛池租用【tg:seogoogle987】,etJ
- https://www.resopal.de/catalogsearch/result/?action=SEARCH&q=必应蜘蛛池租用【tg:seogoogle987】,0rz
- https://www.zutari.com/?s=必应蜘蛛池租用【tg:seogoogle987】,ZEs
- https://www.sweat.com/collections/vendors?q=必应蜘蛛池租用【tg:seogoogle987】,sDT
- https://www.nctsn.org/search?cat=191&query=必应蜘蛛池租用【tg:seogoogle987】,144
- https://www.mynextmove.org/find/search?s=必应蜘蛛池租用【tg:seogoogle987】,37D
- https://blvdseafood.com/?s=必应蜘蛛池租用【tg:seogoogle987】Ywc
- https://www.polliwogs.com/search/必应蜘蛛池租用【tg:seogoogle987】,Twy
- https://www.pearlstonecenter.org/search/必应蜘蛛池租用【tg:seogoogle987】,hu1
- https://www.vocabulary.com/dictionary/必应蜘蛛池租用【tg:seogoogle987】,LfO
- https://www.roberthalf.com/us/en/jobs/all/必应蜘蛛池租用【tg:seogoogle987】dpp
- https://www.goodreads.com/quotes/tag/必应蜘蛛池租用【tg:seogoogle987】T93
- https://www.temu.com/search_result.html?search_key=必应蜘蛛池租用【tg:seogoogle987】JtC
- https://www.teamlab.art/zh-hans/?submit=必应蜘蛛池租用【tg:seogoogle987】,7W9
- https://www.lindseymedicalsupply.com/search/必应蜘蛛池租用【tg:seogoogle987】,XsV
- https://www.whiterock2008.com.tw/search?q=必应蜘蛛池租用【tg:seogoogle987】,lB9
- https://www.abbreviations.com/必应蜘蛛池租用【tg:seogoogle987】rT8
- https://www.randjleather.co.uk/index.php?route=product/search&tag=必应蜘蛛池租用【tg:seogoogle987】,AQX
- https://www.navylookout.com/?ID=nSBR6Ivdu6lZg1yr2SDs30Lo5sTs76yJ&s=必应蜘蛛池租用【tg:seogoogle987】,tSE
- https://www.u-bourgogne.fr/?cat=117&s=必应蜘蛛池租用【tg:seogoogle987】,DYU
- https://www.lauben.com/de/?s=必应蜘蛛池租用【tg:seogoogle987】,OK4
- https://www.teamlab.art/pt/?submit=必应蜘蛛池租用【tg:seogoogle987】,A0S
- https://www.samen-maier.at/search/必应蜘蛛池租用【tg:seogoogle987】,0nR
- https://www.writingforward.com/?action=SEARCH&s=必应蜘蛛池租用【tg:seogoogle987】,kpm
- https://www.tmtpost.com/search?q=必应蜘蛛池租用【tg:seogoogle987】,9Wt
- https://www.whatsonstage.com/search?cat=64&term=必应蜘蛛池租用【tg:seogoogle987】,jhJ
- https://www.polar-tech.com/?action=QUERY&s=必应蜘蛛池租用【tg:seogoogle987】,ilc
- https://www.zisha.com/shop/list.shtml?wap_keyword=必应蜘蛛池租用【tg:seogoogle987】,Xw5
- https://www.sdcard.org/ja/?s=必应蜘蛛池租用【tg:seogoogle987】,CWB
- https://www.libros.unam.mx/catalogsearch/result/?cat=37&dir=asc&format=20&lit=20&manufacturer=3230&mode=list&order=year_edition&q=必应蜘蛛池租用【tg:seogoogle987】,FAK
- https://www.terramania.nl/catalogsearch/result/index/?q=必应蜘蛛池租用【tg:seogoogle987】,WRL
- https://www.rhymezone.com/r/rhyme.cgi?typeofrhyme=oldrel&loc=nojs&Word=必应蜘蛛池租用【tg:seogoogle987】,WQY
- https://www.wilsonart.com/catalogsearch/result/?action=CHECK&q=必应蜘蛛池租用【tg:seogoogle987】,6Vp
- https://www.maine.gov/pfr/professionallicensing/search/node?keys=必应蜘蛛池租用【tg:seogoogle987】,RLw
- https://hsmoa.com/search?query=必应蜘蛛池租用【tg:seogoogle987】z32
- https://www.oikos-tecnics.com/?s=必应蜘蛛池租用【tg:seogoogle987】,Qjb