Hello community,
I mount an .env
file in order to not re-build in case I change this file. With Docker Desktop for Windows I encounted an Operation not permitted
error when reading the file which obviously is required to run my containerized application accordingly. So it’s a blocker for me. The question is. How to fix that error?
What I did so far:
- Change volume mount to
:ro
and removed again - Own the whole
srv
directory recursively byroot
- Own everything by
node
and change toUser node
My compose file:
...
volumes:
- "./.env:/srv/.env"
...
Shell to the container:
whoami: root
ls -la:
-rwxr-xr-x 1 root root 999 Jan 8 10:52 .env
-rwxr-xr-x 1 root root 663 Sep 26 09:50 .eslintrc.js
So the file .eslintrc.js
is copied in the Dockerfile using COPY
instruction. No error reading that file.
The file .env
is mounted through a volume. Everything seems identical but I can’t read that file.
I noticed I get asked everytime by Docker Desktop Filesharing
if I want to share the .env
file. And only for that file. All other files are fine to approve it once.
I know I can change my setup to COPY
the .env
file as well using my Dockerfile (actually already did that in order to continue my work) but I want to use a volume mount for that file.
How can I do that?
Where might the problem be?