No permission for file saving when hosting .net apps on docker.
I'm learning ASP .NET and I'm trying to make a simple API that recieves files and saves them on filesystem. Everything works fine when saving locally, but when running on docker and saving to a volume I always get permission denied.
The problem seems to be caused because owner of the volume is "root" but current user is "app". I'm not really sure how to change it.
21 Replies
Stack Overflow
Docker volume change owner to non-root
I want to create an uploads volume and set its owner to the node user. But upon running the container I find that the volume's owner is root. This is my Docker file:
FROM node:12.21
RUN apt-get upd...
Give this a try
I tried to change ownership and permissions by using RUN command in dockerfile, owner is still root for some reason
@Clean Cock share your Dockerfile
also how you're launching the container
im launching my containers with docker compose, by clicking the green button on the top of visual studio

Where is
/app/images
being made?
also you have chmod chmod
somehowit's after some experimenting, i tried many commands
well
chmod chmod
doesn't make sense
and again, I don't see /app/images being made in that Dockerfile/app seems to be in the main(?), root(?) directory, you cannot go outiside

that... doesn't answer my question
as in, I don't see a
mkdir /app/images
in your Dockerfile, nor somewhere it could be copied from
my docker-compose.yml does the job
volumes from compose are not available during the image build process
You'll want a VOLUME directive in your Dockerfile
one sec
first time hearing about that, gotta read about it
@Clean Cock
the cmod should be unnecesary
you also might need the
USER
bit again in the final
stage, not sure
if so, place it before VOLUME and WORKDIRuhm which user bit?
USER $APP_UID
from the very start of your Dockerfilehm, try this
1.
docker image ls
, find the id of your container's image
2. docker run -it -v images:/app/images --entrypoint /bin/bash ID
that will give you a shell inside the container, check your uid/gid with id
, and then the owner and perms of the images dir with ls -ld /app/images
actually, you'll need to apply a volume too to have the same kind of setup
there, run command fixedim going to sleep now, sorry, ill respond how it went tommorow