我在使用python创建一个Docker容器时遇到很多问题:3.6-alpine for Plotly。 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 docker图像official repository,有一个Dockerfile示例说明了pip步骤:
RUN pip install --no-cache-dir -r requirements.txt
您应该能够直接使用pip而不是venv / bin / pip。
如果你只在里面运行一个应用程序,你真的不需要在docker容器中使用virtualenv。容器已经提供了自己的隔离环境。