为什么dockered centos无法识别点子? [英] Why dockered centos doesn't recognize pip?
问题描述
我想用centos创建一个带有python和几个软件包的容器.我试图在原始centos容器中运行几个命令.一切正常,我已经安装了所有想要的东西.然后,我用通过RUN
执行的相同命令创建了Dockerfile
,我得到了/bin/sh: pip: command not found
可能是什么问题?我的意思是说情况.为什么所有内容都可以在命令行中执行但不能用RUN
执行?我已经尝试了两种变体:
I want to create a container with python and few packages over centos. I've tried to run several commands inside raw centos container. Everything worked fine I've installed everything I want. Then I created Dockerfile
with the same commands executed via RUN
and I'm getting /bin/sh: pip: command not found
What could be wrong? I mean the situation at all. Why everything could be executed in the command line but not be executed with RUN
? I've tried both variants:
RUN command
RUN command
RUN pip install ...
和
RUN command\
&& command\
&& pip install ...
我执行的命令
from centos
run yum install -y centos-release-scl\
&& yum install -y rh-python36\
&& scl enable rh-python36 bash\
&& pip install django
UPD :帮助您找到完整的点.怎么了?
UPD: Full path to the pip helped. What's wrong?
推荐答案
您需要先使用
yum install python-pip
或者如果您需要python3(来自epel)
or if you need python3 (from epel)
yum install python36-pip
如果不确定,请询问yum
:
yum whatprovides /usr/bin/pip
python2-pip-18.1-1.fc29.noarch : A tool for installing and managing Python 2 packages
Repo : @System
Matched from:
Filename : /usr/bin/pip
python2-pip-18.1-1.fc29.noarch : A tool for installing and managing Python 2 packages
Repo : updates
Matched from:
Filename : /usr/bin/pip
python2-pip-18.0-4.fc29.noarch : A tool for installing and managing Python 2 packages
Repo : fedora
Matched from:
Filename : /usr/bin/pip
此输出来自Fedora29,但您应该在Centos/RHEL中得到类似的结果
更新
来自评论
但是当我从docker run -ti centos执行相同的命令时,一切 很好有什么问题吗?
But when I execute same commands from docker run -ti centos everything is fine. What's the problem?
也许您的PATH
坏了吗?你可以尝试完整的点子路径吗?
Maybe your PATH
is broken somehow? Can you try full path to pip?
这篇关于为什么dockered centos无法识别点子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!