警告:以“root”用户身份运行 pip

2023-11-26

我正在 Docker 中制作我的 python Django 应用程序的简单图像。但在构建容器结束时,它会抛出下一个警告(我在 Ubuntu 20.04 上构建它):

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead

如果我在映像中安装 Python 要求,为什么会抛出此警告?我正在使用以下方法构建我的图像:

sudo docker build -t my_app:1 .

我是否应该担心 pip 抛出的警告,因为我知道它会破坏我的系统?

这是我的 Dockerfile:

FROM python:3.8-slim-buster

WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

此行为是在pip 21.1作为“错误修复”。

As of pip 22.1,您现在可以使用参数选择退出警告:

pip install --root-user-action=ignore

您可以使用以下环境在容器中忽略这一点:

ENV PIP_ROOT_USER_ACTION=ignore

#11035

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

警告:以“root”用户身份运行 pip 的相关文章

随机推荐