Docker容器

Python项目dockerfile

本文主要是介绍Python项目dockerfile,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

常规后台项目
# 基于镜像基础
FROM python:3.8
# 设置代码文件夹工作目录 /app
WORKDIR /app
# 复制当前代码文件到容器中 /app
ADD . /app
# 安装所需的包
RUN pip install -r requirements.txt
# Run app.py when the container launches
CMD ["python", "app.py"]

样例:

FROM python:2.7.13

WORKDIR /my_project

COPY ip_light.py .
COPY o_domain.py .
COPY order_center.py .

RUN pip install --upgrade pip
RUN pip install flask

CMD ["python","ip_light.py"]

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

WEB项目
FROM python:3.8.0
RUN mkdir -p /usr/src/app/
ADD . /usr/src/app/
WORKDIR /usr/src/app/
RUN pip install -i https://mirrors.aliyun.com/pypi/simple --upgrade pip
RUN pip install -i https://mirrors.aliyun.com/pypi/simple gunicorn --user
RUN pip install -i https://mirrors.aliyun.com/pypi/simple -r /usr/src/app/requirements.txt
RUN echo "Asia/shanghai" > /etc/timezone
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
CMD ["/bin/bash","-c","gunicorn -c gunicorn_conf.py app:app"]
————————————————
版权声明:本文为CSDN博主「lansye」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lansye/article/details/123386912

这篇关于Python项目dockerfile的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!