【问题标题】:How to Build a Docker Python Image with Plotly?如何使用 Plotly 构建 Docker Python 映像?
【发布时间】:2018-09-04 21:07:58
【问题描述】:

我在使用 python:3.6-alpine for Plotly 创建 Docker 容器时遇到很多问题。 Plotly 还使用 Pandas 和 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 dockerfile plotly alpine


【解决方案1】:

如果你查看 Python docker 镜像official repository,有一个 Dockerfile 示例说明了 pip 步骤:

RUN pip install --no-cache-dir -r requirements.txt

你应该可以直接使用 pip 而不是 venv/bin/pip。

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

【讨论】:

  • 您好 Victor- 更改后,这里是错误输出: Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install -ozezw0la/numpy/setup.py';f=getattr(tokenize, 'open', open)(file);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-externally-managed --compile" 失败,错误代码 1 在 /tmp/pip-install-ozezw0la/numpy/ 命令 '/bin/sh -c pip install --no-cache-dir - r requirements.txt' 返回一个非零代码:1
  • 能否包含您的 requirements.txt?我只是尝试了一个最小的 requirements.txt,它工作得很好。听起来您的软件包版本有问题。您可以尝试在 requirements.txt 中仅使用一个包进行构建来确认。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-19
  • 1970-01-01
  • 1970-01-01
  • 2019-07-05
  • 2019-02-21
  • 1970-01-01
  • 2018-03-09
相关资源
最近更新 更多