fastapi + uvicorn + gunicorn部署时run命令(20210308在用)

本文介绍了使用Docker部署FastAPI应用的详细步骤,包括基于uvicorn和gunicorn的配置,以及优化设置如健康检查、超时管理和镜像加速。同时,还展示了PHP和Node.js应用的Docker运行命令,以及Docker网络创建和IP查找的方法,旨在提升容器化部署的效率和稳定性。

fastapi + uvicorn + gunicorn部署时run命令(20210308在用)

run docker

docker run -d \
--name mqsub \
--restart=always \
--network php-net \
-p 8000:80 \
-v /root/mqsub:/app \
-e KEEP_ALIVE="20" \
-e GRACEFUL_TIMEOUT="20" \
-e TIMEOUT="20" \
mqsub /start-reload.sh

fastapi uvicorn 部署Dockerfile(20210308在用)

#FROM centos/python-36-centos7
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
MAINTAINER sam
USER root

WORKDIR /app

# 下载pip包
RUN python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pycrypto -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install mq_http_sdk  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install aliyunsdkcore -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple aliyun-python-sdk-iot

RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple fastapi
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pydantic
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple uvicorn

#COPY requirements.txt /home/requirements.txt

# 使用淘宝的npm镜像
#RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
#RUN pip install -r requirements.txt

#ENTRYPOINT [ "/bin/bash", "/home/entry-point.sh"]
#ENTRYPOINT  uwsgi --ini /home/hello.ini
#CMD ["uwsgi","--ini", "/home/hello.ini"] #启动uwsgi

nodejs的docker运行命令

docker run -d \
    --restart=always \
    -v /root/xy.api:/app \
    --network php-net \
    -p 3000:3000 \
    --name xyys.nodejs \   #镜像名
    xyys.nodejs \          #容器名
    node /app/app.js    #运行命令

php的docker运行命令

docker run -d \
--restart=always \
--name php-web \
--network php-net \
-p 9001:9000 \
-v /www/nginx/apps:/usr/share/nginx/html \
php:5.6-fpm

建立镜像命令

sudo docker build -t mqsub .

查看docker ip地址

#查看IP;
[root@localhost ~]# docker inspect myphp-fpm | grep "IPAddress"
 "SecondaryIPAddresses": null,
 "IPAddress": "172.17.0.3",
 "IPAddress": "172.17.0.3",
#创建一个docker网络,使用docker来连接多个容器
[root@localhost ~]# docker network create -d bridge php-net
#加入docker网络的容器执行 docker run 命令时要加参数:--network
--network php-net \

docker镜像image拉取速度过慢 - 仓库源:中科大速度最快(docker pull)

#创建、修改配置文件: /etc/docker/daemon.json 
vim /etc/docker/daemon.json          # 编辑daemon.json 
{
    "registry-mirrors": ["http://docker.mirrors.ustc.edu.cn"] 
} 
systemctl restart docker                  # 重启docker服务

如何改变

*强调

适合你的列表

  • 项目
    • 项目
      • 项目
  1. 项目1
  2. 项目2
  3. 项目3
  • 计划任务
  • 完成任务

一个表格

一个简单的表格是这么创建的:

项目Value
电脑$1600
手机$12
导管$1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值