An empty node_modules folder is being created at the host whenever a container is spun up

I am new to docker and trying to understand its behaviour and working. I have been trying to dockerize my node-app. Below is the docker file.

Dockerfile:

FROM node

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

CMD [ "npm","start" ]

now I am using bind-mount and volumes to run the container with the following commnad:

docker run -d --rm -p 3000:80 --name feedback-app -v /app/node_modules  -v "D:\Practice Courses\Docker\data-volumes-01-starting-setup:/app"   feedbakcapp:bind-mount

before running this command local working directory is without the node_modules but as soon as I run the command, an empty node_modules folder is being created in the local (host) Dir.

I cannot figure out why is it happening.

You’re bind-mounting the /app directory, then you’re mounting a volume into that same directory (which creates node_modules within it).

The host directory bound to /app reflects whatever’s inside it, and the node_modules directory is created there

The contents of the node_modules will be stored within the volume itself, thud the directory created on the host is empty