I'm trying to create POST action to upload images in Django. Using python:3.9-alpine3.13 docker image.
Dockerfile contains those lines:
RUN \
adduser \
--disabled-password \
--no-create-home \
djuser && \
mkdir -p /vol/web/media && \
mkdir -p /vol/web/static && \
chown -R djuser:djuser /vol && \
chmod -R 755 /vol
USER djuser
After this I did docker-compose build and tried this command:
docker-compose run --rm app sh -c "whoami && cd ../vol/web && ls -l && mkdir ./media/uploads"
And got this
djuser
total 8
drwxr-xr-x 2 755 djuser 4096 Dec 5 11:07 media
drwxr-xr-x 2 755 djuser 4096 Dec 5 11:07 static
mkdir: can't create directory './media/uploads': Permission denied
So as I see: I tried mkdir from django-user that have 755 permission on directory where I want to create a new directory. Any thoughts why this doesn't work?
Creating directories using sudo and after that chmod them is not a good idea here (i think) because script must create directories. And using sudo or changing to the root everytime...