【发布时间】:2018-11-24 19:06:25
【问题描述】:
我有一个看起来像这样的旧 dockerfile
FROM ubuntu:16.04
ENV VISUAL=vim
ENV EDITOR=$VISUAL
ENV TERM=xterm
ENV TERMINFO=/etc/terminfo
ENV PYTHONIOENCODING=utf-8
RUN apt-get --yes update && apt-get --yes upgrade && apt-get --yes install python \
python-dev \
python-pip
<...lots of other apt-get install...>
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
<...other staffs>
效果很好,但我想通过减少图层来减小图像大小。所以我合并了最后两行
RUN pip install --upgrade pip && \
pip install -r requirements.txt
但是构建失败了……
Step 15/45 : RUN pip install --upgrade pip && pip install -r requirements.txt
---> Running in b96971e60263
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
Found existing installation: pip 8.1.1
Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-18.1
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
合并这两行时我错过了什么?
【问题讨论】:
标签: python docker pip dockerfile