如果我使用以下 Dockerfile:
FROM python:3.11-bullseye
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY requirements.txt /app
RUN pip install uv && uv pip install --system --no-cache -r requirements.txt
然后
requirements.txt
中的软件包安装就可以了。但如果我将第一行更改为
FROM bitnami/deepspeed:0.14.0
然后突然我收到错误
#8 [4/4] RUN pip install uv && uv pip install --system --no-cache -r requirements.txt
#8 0.629 Defaulting to user installation because normal site-packages is not writeable
#8 0.807 Collecting uv
#8 0.867 Downloading uv-0.1.18-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (23 kB)
#8 0.896 Downloading uv-0.1.18-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB)
#8 2.013 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.0/11.0 MB 9.9 MB/s eta 0:00:00
#8 2.947 Installing collected packages: uv
#8 3.209 Successfully installed uv-0.1.18
#8 3.421 /bin/bash: line 1: uv: command not found
#8 ERROR: process "/bin/bash -o errexit -o nounset -o pipefail -c pip install uv && uv pip install --system --no-cache -r requirements.txt" did not complete successfully: exit code: 127
------
> [4/4] RUN pip install uv && uv pip install --system --no-cache -r requirements.txt:
0.629 Defaulting to user installation because normal site-packages is not writeable
0.807 Collecting uv
0.867 Downloading uv-0.1.18-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (23 kB)
0.896 Downloading uv-0.1.18-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB)
2.947 Installing collected packages: uv
3.209 Successfully installed uv-0.1.18
3.421 /bin/bash: line 1: uv: command not found
------
Dockerfile.mini:11
--------------------
9 |
10 | # Install dependency packages
11 | >>> RUN pip install uv && uv pip install --system --no-cache -r requirements.txt
--------------------
ERROR: failed to solve: process "/bin/bash -o errexit -o nounset -o pipefail -c pip install uv && uv pip install --system --no-cache -r requirements.txt"
uv
在 bitnami/deepspeed:0.14.0
Docker 镜像中安装软件包?
安装的
uv
二进制文件不在 PATH 上,大概是因为它不是常规的 Python 包装脚本,pip
不会打印出有关该问题的有用警告。
手动参考
.local
安装的uv
:
RUN pip install uv && ~/.local/bin/uv pip install --system --no-cache -r requirements.txt
请注意,
--system
可能会失败,因为该图像显然没有像root
那样运行这些命令。
(就我个人而言,我可能不会使用
bitnami/deepspeed
图像。)
让它工作:
FROM bitnami/deepspeed:0.14.0
USER root
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY requirements.txt /app
RUN pip install uv && uv pip install --python $(which python) --no-cache -r requirements.txt