C#C
C#2y ago
bdcp

Docker non-root access volume for runtime image

I have this Dockerfile

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

USER app
RUN mkdir /home/app/data
WORKDIR /home/app

COPY ./publish .

ENTRYPOINT ["dotnet", "MyProject.dll"]


Something like File.WriteAllText("/home/app/data/file.txt", "lorem ipsum") get permission denied when the volume is mounted in linux

 docker run --rm \
    -v ./testdata:/home/app/data \
    -e RUN_ON_STARTUP=true \
    $image_name 

I've tried many things related to docker. I suspect it's how the dotnet/runtime image is setup might be the issue. But i'm not that advanced.

Ideally, i would like to save the file to /data instead of /home/app/data
Was this page helpful?