使用 docker 构建一个 web 应用程序

这篇博客介绍了如何在Docker容器中运行Python Flask应用,通过`docker ps`检查运行的容器,并详细说明了Docker如何将容器的5000端口映射到主机的不同端口,以实现通过浏览器访问Web应用的功能。
摘要由CSDN通过智能技术生成
  • 在docker容器中运行一个 Python Flask 应用来运行一个web应用
#载入镜像
[root@localhost ~]# docker pull training/webapp
Using default tag: latest
latest: Pulling from training/webapp
[DEPRECATION NOTICE] registry v2 schema1 support will be removed in an upcoming release. Please contact admins of the docker.io registry NOW to avoid future disruption.
e190868d63f8: Pull complete 
909cd34c6fd7: Pull complete 
0b9bfabab7c1: Pull complete 
a3ed95caeb02: Pull complete 
10bbbc0fc0ff: Pull complete 
fca59b508e9f: Pull complete 
e7ae2541b15b: Pull complete 
9dd97ef58ce9: Pull complete 
a4c1b0cb7af7: Pull complete 
Digest: sha256:06e9c1983bd6d5db5fba376ccd63bfa529e8d02f23d5079b8f74a616308fb11d
Status: Downloaded newer image for training/webapp:latest
docker.io/training/webapp:latest
[root@localhost ~]# docker run -d -P training/webapp python app.py
6eded223c4242208e465da1da1ab382455c4f78c560567c1e068d62a166bfcb2
#参数说明:

-d:让容器在后台运行。
-P:将容器内部使用的网络端口映射到我们使用的主
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值