您现在的位置是:热点 >>正文
云计算核心技术Docker教程:将Python的镜像作为容器运行
热点56396人已围观
简介...
在上一个模块中,我们创建了示例应用程序,然后创建了一个用于生成映像的 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: Connecketion refused
如您所见,我们的curl命令失败了,因为与我们的服务器的连接被拒绝。这意味着,我们无法在端口 5000 上连接到本地主机。这是意料之中的,因为我r教们的容器是独立运行的,包括网络。让我们停止容器并使用我们本地网络上发布的端口 5000 重新启动。
要停止容器,请按 ctrl-c。这将使您返回到终端提示。
要为程:我们的容器发布端口,我们将在命令中使用--publish flag(-p简称) docker run。--publish命令的格式为[host port]:[cont将Painer port]. 因此,如果我们想将容器内的端口 5000 暴露给容器外的端口 3000,我们将传递3000:5000给--publish标志。
我们在容器yt中运行 Flask 应用程序时没有指定端口,默认是 5000。如果我们希望我们之前的请求在 5000 端口工作,我们可以将主机的 5000 端口映射到容器的 5000 端口:
$ dhoocker run --publish 5000:5000 python-docker
现在,让我们从上面重新运行 curl 命令。记得打开一个新的终端。
$ curl localhn的ost:5000
Hello, Docker!
成功!我们能够通过端口 5000 连接到在容器内运行的应用程序。切换回运行容器的终端,您应该会看到 GET 请求记录到镜像控制台。
[31/Jan/2021 23:39:31] "GET / HTTP/1.1" 200 -
按 ctrl-c 停止容器。
Tags:
相关文章
谷歌加速推进线下复工:部分人下月返工,为远程办公设置限制条件
热点查看最新行情 相关新闻:亚马逊宣布恢复办公室上班时间表:少数员工在夏天 多数在秋季 新浪科技讯 北京时间4月1日早间消息,据报道,知情人士透露,谷歌周三对员工表示,预计部分人可以在下月返回办公室工作,...
【热点】
阅读更多联邦法官裁定针对苹果数字内容购买和租赁的集体诉讼可以继续进行
热点一名联邦法官驳回了苹果公司提出的动议,即驳回该公司在销售数字内容时使用 “购买 ”和 “租赁 ”标签的集体诉讼案。正如《好莱坞报道》首先报道的那样,该诉讼现在可以继续进行,尽管在进入审判前还可能会达成...
【热点】
阅读更多标签: 苹果
热点撰文 | 雁 秋 编辑 | 李信马 题图 | IC Photo 在英伟达、微软相继跻身四万亿美元市值俱乐部后,曾经的领跑者苹果,成为第三位成员。 据苹果刚刚披露的2025财年第四季度财报显示,本季总营...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.oikos-tecnics.com/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,8Qj
- https://www.maigoo.com/search/?block=&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,OCd
- https://www.niaogebiji.com/pc/article/search?keyword=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,hRl
- https://www.sbaad.no/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,xGj
- https://www.teamlab.art/pt/?submit=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,lpY
- https://www.zalora.sg/catalog/?cat=112&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,AVz
- https://www.nyif.com/catalogsearch/result/index/?f=sarbanesoxleyU&index=me_cms_pe&lit=20&mode=list&p=1&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,GuD
- https://www.vocabulary.com/dictionary/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,GmI
- https://www.klatreverden.no/search?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,FEB
- https://www.riohondo.edu/?action=QUERY&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,7QZ
- https://www.paxnet.co.kr/search/jongmok?kwd=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】Wt7
- https://www.polliwogs.com/search/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,Ntb
- https://www.teamlab.art/es/?submit=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,yh5
- https://www.jusoen.com/addreng.asp?p1=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】Qmz
- https://www.navylookout.com/?ID=nSBR6Ivdu6lZg1yr2SDs30Lo5sTs76yJ&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,S9R
- https://www.solerpalau.com/en-en/catalogsearch/result/?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,8cy
- https://www.welshmountainzoo.org/shop/index.php?routeproduct/search&tag=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,9aC
- https://blvdseafood.com/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】B9z
- https://www.trockenmittel.ch/catalogsearch/result/?iC=ZM3&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,oTT
- https://www.abbreviations.com/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】SOk
- https://www.abbreviations.com/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】oeP
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】zOk
- https://www.tailoy.com.pe/catalogsearch/result/?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,o4g
- https://www.flickr.com/photos/tags/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】sbv
- https://www.olx.ba/pretraga?trazilica=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,8Qz
- https://www.remit.co.jp/vi/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,xNH
- https://www.tiktok.com/tag/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,f3Y
- https://www.paxnet.co.kr/search/jongmok?kwd=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】R0Y
- https://www.normani.de/search?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,N65
- https://www.synonyms.com/antonyms/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,vWr
- https://www.springfieldlibrary.org/library/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,kPe
- https://www.sebson.de/en/search?query=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,I7Q
- https://www.realsporting.com/buscador?buscar=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,phC
- https://www.swanagerailway.co.uk/search?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,Vg0
- https://www.paspaley.com/catalogsearch/result/?action=QUERY&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,Fi3
- https://www.rollingstone.it/?ID=DVMeu3AlmzZE1cuJ2FmgmO5TSCQRb3yh&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,0vW
- https://www.lechzuers.com/de/search?cat=163&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,cEB
- https://www.kubb-tool.bfs.admin.ch/en/search?action=CHECK&q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,44F
- https://www.nextavenue.org/?action=QUERY&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,kWG
- https://www.roberthalf.com/us/en/jobs/all/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】eQH
- https://m.shoppinghow.kakao.com/m/search/q/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】L9R
- https://www.posten-portal.de/search?query=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,CDF
- https://www.teacherspayteachers.com/Browse/Price-Range/Free/Search:谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,yp9
- https://www.scq.ubc.ca/?page=2&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,njR
- https://www.livehindustan.com/tags/谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,ZXM
- https://www.tullygroup.us/?ID=hbkq8jFjrQlVRrwzEmvoUJJAY4e1Lfo5&s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,mgV
- https://search.danawa.com/dsearch.php?query=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】bVq
- https://www.lauben.com/de/?s=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,Mz7
- https://zhidao.baidu.com/index/?action=QUERY&word=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,sdF
- https://www.nyif.com/catalogsearch/result/?q=谷歌霸屏24小时见效-实现思路与效果衡量【tg:seogoogle987】,DUC