李明
|
python程序
mkdir flask-hello-worldcd flask-hello-world/ vim app.py
image.png from flask import Flask app = Flask(__name__)@app.route('/')def hell(): return "hello docker public attention:idig88"if __name__=='__main__': app.run(port=8888)
python app.py
image.png #安装flask插件sudo yum -y install epel-release sudo yum -y install python-pip pip install flask python app.py
image.png 编写Dockerfile文件vim Dockerfile
FROM python:2.7 LABEL maintainer="zhugeaming"RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list RUN echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list RUN echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list RUN echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list RUN apt-get update RUN pip install flask COPY app.py /app/ WORKDIR /app EXPOSE 8888 CMD ["python","app.py"]
image.png
docker image ls
运行containerdocker run zhugeaming/flask-hello-world
#后台运行docker run -d zhugeaming/flask-hello-world
PS:本次就是做了个实战,通过四步
|
2018-09-02 10:45:57