I am learning Docker and I am stuck with this permission issue. I have created a simple React app and created its image. Dockerfile I used Dockerfile: FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
Now when starting the container I am using volume (-v) so that I can use my file system's file instead of snapshot. It works as expected when I use command -> sudo docker run -p 3000:3000 -v "$(pwd)":/app
But now I want that my container to use node_modules from snapshot only and rest files from my file system. For this I have used command -> sudo docker run -p 3000:3000 -v /app/node_modules -v "$(pwd)":/app
And I get this error -> [eslint] EACCES: permission denied, mkdir '/app/node_modules/.cache'
ERROR in [eslint] EACCES: permission denied, mkdir '/app/node_modules/.cache'
vishal@vishal-ThinkPad-E14-Gen-2:~/implementations/Self/docker_compose/083 81-docker-compose-running-tests/frontend2$ sudo docker run -p 3000:3000 -v /app/node_modules -v "$(pwd)":/app 547ddab2b759
> frontend2@0.1.0 start
> react-scripts start
(node:25) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:25) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
Starting the development server...
Failed to compile.
[eslint] EACCES: permission denied, mkdir '/app/node_modules/.cache'
ERROR in [eslint] EACCES: permission denied, mkdir '/app/node_modules/.cache'
webpack compiled with 1 error