Docker Flask
新建 app.py
文件python
From flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Flask Docker Hello Word' if __name__ == '__main__': app.run(debug=True,host='0.0.0.0')
新建 requirements.txt
文件docker
Flask==0.10.1
新建 Dockerfile
flask
FROM ubuntu:latest MAINTAINER dingdayu "6144220992@qq.com" RUN sed -i 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/mirrors\.aliyun\.com\/ubuntu\//g' /etc/apt/sources.list RUN apt-get -qqy update && \ apt-get install -y python-pip python-dev build-essential && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY . /app WORKDIR /app RUN pip install -r requirements.txt ENTRYPOINT ["python"] CMD ["app.py"]
docker build -t flask-docker-hello:latest .
docker run -d -p 5000:5000 flask-docker-hello