Getting Permission denied: '/vol/web/media' when trying to create file in my django application

Here is my dockerfile.

    FROM python:3.9-alpine3.13
    COPY ./requirements.txt /requirements.txt
    COPY ./electron /electron
    COPY ./scripts /scripts
    WORKDIR /electron
    EXPOSE 8000
    RUN apk add --no-cache --virtual .build-deps gcc musl-dev
    RUN python3.9 -m venv /py && \
        /py/bin/pip install --upgrade pip setuptools wheel && \
        apk add --update --no-cache postgresql-client && \
        apk add --update --no-cache --virtual .temp-deps \
            build-base postgresql-dev musl-dev linux-headers && \
        mkdir -p /vol/web/media && \ <----- The problem is located at this level
        /py/bin/pip install -r /requirements.txt && \
        adduser --disabled-password --no-create-home ozangue && \
        chown -R ozangue:ozangue /vol && \
        chmod -R 755 /vol && \
        chown -R ozangue:ozangue /vol/web/media && \
        chmod -R 755 /vol/web/media && \
        chmod -R +x /scripts
    ENV PATH="/scripts:/py/bin:$PATH"

USER ozangue

CMD [""]

I cannot save a model containing a file. Because this file must be saved in /vol/web/media
The part of the code that poses a problem is as follows (in

file = request.FILES["excel_file"]
file_obj = FileModelXSL(file=excel_file)
fichier_obj =


STATIC_URL = '/static/static/'
MEDIA_URL = '/static/media/'

MEDIA_ROOT = '/vol/web/media'
STATIC_ROOT = '/vol/web/static'

When I build the container, I don't get any errors but I have the impression that /vol/web/media: mkdir -p /vol/web/media is not created. But if it was not created the line chmod -R 755 /vol/web/media should have returned an error.
Need help please

Back to Top