docker部署flask项目


一、环境准备
docker中安装uwsgi报错:ERROR: Command errored out with exit status 1,需要安装以下组件
ubuntu: apt install build-essential   #安装gcc
ubuntu: apt install python3-dev
centos: yum install python3-devel
centos: yum install gcc

二、安装uwsgi
pip3 install uwsgi

三、flask.ini文件内容
root@Ubuntu:~/southpark# cat flask.ini

[uwsgi]
master=true
processes=2
http=0.0.0.0:5000
wsgi-file=southrun.py
callable=app
chmod-socket=666
touch-reload=/root
threads=2
vacuum=true

四、启动flask项目
root@Ubuntu:~/southpark# uwsgi --ini flask.ini          #启动后日志在终端显示
root@Ubuntu:~/southpark# uwsgi --ini flask.ini --daemonize /var/log/uwsgi.log      #后台运行,日志输出到指定文件