Search code examples
pythondockerpippython-poetrydocker-build

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager


I get this Warning message in Docker image Build stage. Is there anyway to supress this warning ? i want to keep using root though.

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: https://pip.pypa.io/warnings/venv

My Dockerfile :

FROM python:3.8.11-slim-buster
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    POETRY_VERSION=1.1.13

RUN python3 -m pip install poetry==$POETRY_VERSION

COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false \
    && poetry install --no-interaction --no-dev --no-ansi

Solution

  • As is discussed on the github, see the following links, I don't claim to be an expert on pip but this information was extremely helpful when I had something similar to this.

    See pfmoore's comment on May 28, 2021

    See multiple comments below

    recommend looking at comments made by hholst80, pradyunsg, and potiuk on Oct 8, 2021

    or as suggested by fnymnx:

    Check out this StackOverflow question as well