环境
代码语言:javascript复制Docker
Flask
代码
新建 app.py
文件
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
文件
Flask==0.10.1
Dockerfile
新建 Dockerfile
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"]
编译
代码语言:javascript复制docker build -t flask-docker-hello:latest .
运行
代码语言:javascript复制docker run -d -p 5000:5000 flask-docker-hello