0

In order to mitigate the following warning,

WARNING: The directory '/home/jovyan/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I would usually run pip as

sudo -H pip install -r requirements.txt

Now I am executing pip within a Dockerfile:

FROM python3.7-slim
USER root
COPY requirements.txt /app/requirements.txt
RUN pip install -U setuptools pip \
    && pip install -r /app/requirements.txt

How would I activate the -H flag?

Is there another way to activate the cache?

jtlz2
  • 7,700
  • 9
  • 64
  • 114
  • 1
    You're already root and all the environment variables that would normally be set it the Docker environment are set; if you need something else, an `ENV` directive will set it. The linked question has a pretty detailed recipe on enabling pip's cache that doesn't need any special settings (the BuildKit component it references is now the default builder). – David Maze May 20 '21 at 10:49
  • @DavidMaze Perfect - thank you so much! – jtlz2 May 20 '21 at 10:51

0 Answers0