Setting permissions for Flask Session in Docker Container

When building and running my custom Docker image for a Python Flask application that I am building, I get a permission error.:

PermissionError: [Errno 13] Permission denied:

I have tried giving maximum permissions to the ‘project’ directory, as well as not setting the encompassing ‘project’ directory as a volume.

My image is generated from the following Dockerfile:

FROM python:3.5

RUN apt-get update
RUN apt-get install -y --no-install-recommends 
        libatlas-base-dev gfortran nginx supervisor

RUN pip3 install uwsgi

RUN mkdir project
VOLUME /project

COPY requirements.txt /project/requirements.txt

RUN pip3 install -r /project/requirements.txt

RUN useradd --no-create-home nginx

RUN rm /etc/nginx/sites-enabled/default
RUN rm -r /root/.cache

COPY nginx.conf /etc/nginx/
COPY flask-site-nginx.conf /etc/nginx/conf.d/
COPY uwsgi.ini /etc/uwsgi/
COPY supervisord.conf /etc/

COPY /app /project/app

WORKDIR /project

EXPOSE 5000:80

CMD ["/usr/bin/supervisord"]

Other errors seem to indicate that the lack of permissions is disallowing the folder ‘project/flask_session’ to be generated. I am using a framework called Flask Session, that generates the flask_session folder in my working directory in which user data is saved for a session. Thank you for in advance for any help or advice!

Source: StackOverflow