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

马德厚
2023-12-01

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
 类似资料: