Docker giving permission issues in django

Following This Tutorial

Basically my issue is that when I try to run a certain command, I get a permission error. This ends up affecting other parts of my workflow despite not having an immediate impact.
When Running:

RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*

I Get:

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

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

And then oddly, I go to run:

docker-compose -f docker-compose.prod.yml exec app python manage.py migrate --noinput

I get a weird error saying:

estimate_creator.TopLevelService.service_image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".

I do have Pillow installed, and there isn’t an issue with it in my development environment.

No problem though, I’ll just install it. So I run:

docker-compose -f docker-compose.prod.yml exec app python -m pip install Pillow

And see:

Requirement already satisfied: Pillow in /usr/local/lib/python3.8/site-packages (6.2.1)

Okay… I then try to uninstall and reinstall I get this traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/shutil.py", line 780, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/site-packages/PIL/' -> '/tmp/pip-uninstall-opp36exc'

What do you think is going on?

I have tried commenting out the last line of the dockerfile which changes users to no effect.

###########
# BUILDER #
###########

# pull official base image
FROM python:3.8.0-alpine as builder

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev zlib

#########
# Pillow #
#########

RUN apk add build-base python-dev py-pip jpeg-dev zlib-dev

#########
# Pillow #
#########

# install dependencies
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt


#########
# FINAL #
#########

# pull official base image
FROM python:3.8.0-alpine

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
RUN addgroup -S app && adduser -S app -G app

# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

# install dependencies
RUN apk update && apk add libpq
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*

# copy project
COPY . $APP_HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME

# change to the app user
USER app

Hi @austincollinpena
Where u able to find a solution for your above problem. Since I am stuck at the same point where I am getting the same error
Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command “python -m pip install Pillow”.

can you reply back asap.

P.S. I have followed the same blog Tutorial from testdriven.io