如何在 docker 中使用 pip 和 openshift 镜像 ubi8-python:3.11

问题描述 投票:0回答:1

我使用这个docker文件

FROM <my_enterprise_nexus_repository>:18444/ubi8-python:3.11
**strong text**
# Add application sources with correct permissions for OpenShift
USER 0
ADD src .
RUN chown -R 1001:0 ./
USER 1001

ENV ENABLE_PIPENV=True

# Install the dependencies
RUN pip install -U "pip>=19.3.1" && \
    pip install -r requirements.txt 

# Run the application
CMD ["python", "main.py"]

我想使用 ubi8-python:3.11 源通过 docker 为我的 python 项目创建一个映像

没用,我不知道该怎么办

当我跑步时

docker build -t sample_project --rm .

我有这个错误

#10 [4/4] RUN pip install -U "pip>=19.3.1" &&     pip install -r requirements.txt
#10 0.198 /bin/sh: pip: command not found
#10 ERROR: process "/bin/sh -c pip install -U \"pip>=19.3.1\" &&     pip install -r requirements.txt" did not complete successfully: exit code: 127
------
 > [4/4] RUN pip install -U "pip>=19.3.1" &&     pip install -r requirements.txt:
0.198 /bin/sh: pip: command not found
------
Dockerfile:14
--------------------
  13 |     # Install the dependencies
  14 | >>> RUN pip install -U "pip>=19.3.1" && \
  15 | >>>     pip install -r requirements.txt
  16 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install -U \"pip>=19.3.1\" &&     pip install -r requirements.txt" did not complete successfully: exit code: 127

我尝试添加一些

yum install python-pip
,但我有同样的错误:
yum: command not found

我怎样才能完成这项工作?

python docker pip dockerfile openshift
1个回答
0
投票

在“furas”的帮助下,我找到了解决方案

命令

whereis python
给出
/opt/python/bin/python3.11

命令

wereis pip
给出
/opt/python/bin/pip3.11

所以我可以使用

RUN  /opt/python/bin/pip3.11 install -r requirements.txt

而不是

RUN  pip install -r requirements.txt

© www.soinside.com 2019 - 2024. All rights reserved.