如何在 CentOS7 Docker 容器中安装 python-pip

Be *_*ers 13 python pip docker centos-7

我正在尝试构建一个包含 pip 的 docker 容器。

我在 CentOS 7 上。

这是运行 docker build 命令的片段:

Step 3 : RUN yum -y install python-pip
 ---> Running in 25d1ba46e6dc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.vcu.edu
 * extras: mirror.clarkson.edu
 * updates: mirrors.unifiedlayer.com
No package python-pip available.
Error: Nothing to do
2015/02/13 19:23:48 The command [/bin/sh -c yum -y install python-pip] returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)

我会发布我的 Dockerfile,但似乎标准 CentOS 发行版中没有 python-pip,因为这也失败了:

sudo yum -y install python-pip
[sudo] password for theuser: 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.thelinuxfix.com
 * extras: mirrors.xmission.com
 * updates: mirrors.tripadvisor.com
No package python-pip available.
Error: Nothing to do
Run Code Online (Sandbox Code Playgroud)

有关于解决主机系统安装问题的链接:http : //www.liquidweb.com/kb/how-to-install-pip-on-centos-7/ 这涉及使用 rpm 或 curl。我认为这对 Docker 来说有点混乱。

另外,如果 CentOS 从标准发行版中删除了 pip,也许他们有充分的理由,我不应该使用蛮力来安装它。

这在 Ubuntu 或其他发行版中似乎不是问题。只是 CentOS 7。

我的简洁问题是:在 CentOS 7 中安装 pip(或替代方法)的首选方法是什么?

Be *_*ers 18

在 Dockerfile 中使用它允许我安装 pip:

RUN yum -y install epel-release && yum clean all
RUN yum -y install python-pip && yum clean all
Run Code Online (Sandbox Code Playgroud)

这似乎比使用 rpm 或 curl 干净得多。

如果仍然失败,请尝试:

RUN yum -y install --enablerepo="epel" python-pip && yum clean all
Run Code Online (Sandbox Code Playgroud)