【发布时间】:2016-05-03 21:39:41
【问题描述】:
在运行 Docker 构建(使用 Jenkins CI)时,升级 pip(docker 文件的最后一行)失败。我需要它来升级版本 8.1.1,正如它在日志中所建议的那样,因为我的部署因 PIP 版本不匹配而失败。
Dockerfile
FROM ubuntu:14.04
FROM python:3.4
# Expose a port for gunicorn to listen on
EXPOSE 8002
# Make a workdir and virtualenv
WORKDIR /opt/documents_api
# Install everything else
ADD . /opt/documents_api
# Set some environment varialbes for PIP installation and db management
ENV CQLENG_ALLOW_SCHEMA_MANAGEMENT="True"
RUN apt-get update
RUN apt-get install -y python3-pip
RUN pip3 install --upgrade pip
这是错误:
Step 15 : RUN pip3 install --upgrade pip
19:46:00 ---> Running in 84e2bcc850c0
19:46:04 Collecting pip
19:46:04 Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
19:46:04 Installing collected packages: pip
19:46:04 Found existing installation: pip 7.1.2
19:46:04 Uninstalling pip-7.1.2:
19:46:05 Successfully uninstalled pip-7.1.2
19:46:10 Exception:
19:46:10 Traceback (most recent call last):
19:46:10 File "/usr/local/lib/python3.4/shutil.py", line 424, in _rmtree_safe_fd
19:46:10 os.unlink(name, dir_fd=topfd)
19:46:10 FileNotFoundError: [Errno 2] No such file or directory: 'pip'
19:46:10 You are using pip version 7.1.2, however version 8.1.1 is available.
【问题讨论】:
-
我使用相同的 Dockerfile 在我的环境中运行,它运行良好。这是日志的输出:pastebin.com/4qAZLKH1。一切都很顺利。没有错误,没有问题。
-
尝试删除您拥有的 ubuntu:14.04 和 python:3.4 映像。重建后,Docker 将再次下载它,可能存在一些问题。对我来说,新鲜的图像效果很好。
-
您是否尝试过在不升级 pip 的情况下获取可运行的映像,以便您可以执行 docker exec ... bash 并附加到 shell 以查看 pip 的位置结束了 - 用什么名字?我主要将基于 Centos 的图像与 both Python2 和 Python3 一起使用,所以我知道我最终会同时使用 pip2 和 pip3,但基于 Ubuntu 的图像可能会有所不同,具体取决于您安装的 Python 版本。
-
这可能是一个长镜头,但也许升级中的
--导致运行语句出现问题,您是否尝试过RUN pip3 install -U pip。