Docker 部署简单flask应用

2019-10-30 11:01:30 浏览数 (1)

1、vi Dockerfile FROM centos:7

RUN yum install -y python3 RUN pip3 install flask COPY hello.py /tmp/hello.py EXPOSE 5000 CMD ["python3","/tmp/hello.py"]

2、vi hello.py

!/usr/bin/env python

from flask import Flask app = Flask(name)

@app.route('/hi') def hello_world(): return 'Hello World!' if name == 'main': app.run(host='0.0.0.0', port=5000)

3、docker build -t firstflask .

4、 docker run -d -P firstflask

firewall-cmd --add-port=32768/tcp --permanent

firewall-cmd --reload

image.png

0 人点赞