from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0')
requirements.txt
Flask==2.2.2
Dockerfile:
FROM python:3.8.6
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
CMD ["python", "/app/main.py"]
EXPOSE 5000
1.打包成docker image
docker build -t pythonserver .
2.运行容器
docker run -it -d -p 5001:5000 --name=pythonserver pythonserver
标签:__,pythonserver,flask,app,部署,Flask,docker
From: https://www.cnblogs.com/dagger9527/p/16823544.html