如何使用Plotly构建Docker Python映像?

如何使用Plotly构建Docker Python映像?,python,dockerfile,plotly,alpine,Python,Dockerfile,Plotly,Alpine,我在使用python:3.6-alpine for Plotly创建Docker容器时遇到很多问题。Plotly还使用熊猫和Numpy。当我运行下面的Dockerfile时,“run venv/bin/pip install-r requirements.txt”失败。任何人对此有建议,我是否缺少要求 FROM python:3.6-alpine RUN adduser -D visualdata RUN pip install --upgrade pip WORKDIR /home/vi

我在使用python:3.6-alpine for Plotly创建Docker容器时遇到很多问题。Plotly还使用熊猫和Numpy。当我运行下面的Dockerfile时,“run venv/bin/pip install-r requirements.txt”失败。任何人对此有建议,我是否缺少要求

FROM python:3.6-alpine

RUN adduser -D visualdata

RUN pip install --upgrade pip

WORKDIR /home/visualdata

COPY requirements.txt requirements.txt
RUN python -m venv venv
RUN venv/bin/pip install -r requirements.txt
RUN venv/bin/pip install gunicorn
#RUN venv/bin/pip install install python3-pymysql

COPY app app
COPY migrations migrations
COPY visualdata.py config.py boot.sh ./
RUN chmod a+x boot.sh

ENV FLASK_APP visualdata.py

RUN chown -R visualdata:visualdata ./
USER visualdata

EXPOSE 8000
ENTRYPOINT ["./boot.sh"]

如果查看Python docker图像,有一个Dockerfile示例演示了pip步骤:

RUN pip install --no-cache-dir -r requirements.txt
您应该能够直接使用pip而不是venv/bin/pip


如果只在docker容器中运行一个应用程序,那么实际上不需要在docker容器中使用virtualenv。容器已经提供了它自己的隔离环境。

您可以包括构建映像时出现的错误吗?您好,Victor-更改后,以下是错误输出:Command“/usr/local/bin/python-u-c”import setuptools,tokenize__文件_uu='/tmp/pip-install-ozezw0la/numpy/setup.py';f=getattr(标记化“打开”,打开)(文件);code=f.read().replace('\r\n','\n');f、 close();exec(compile(code,file,'exec'))“install--record/tmp/pip-record-vw8kl0es/install-record.txt--single version external managed--compile”在/tmp/pip-install-ozezw0la/numpy/命令“/bin/sh-c pip install--no cache dir-r requirements.txt”中失败,错误代码为1,返回了一个非零代码:1可以包含您的requirements.txt吗?我只是尝试了一个minimal requirements.txt,效果很好。听起来您的软件包版本有问题。您可以通过尝试在requirements.txt中仅使用一个包进行构建来确认。