Why node_modules in host are empty after docker container started?
I’m with Docker for Mac. When i run docker-compose up -d all go right, but it create a node_modules folder on my computer but it’s empty. I go into the bash of my container and ls node_modules, all the packages was there.
How can i get the content on the container on my computer too?
My Dockerfile
# Use an official node image as base image
FROM node:18
# Set the working directory in the container
WORKDIR /app
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install the app dependencies
RUN npm install
# Copy the rest of the app source code to the container
COPY . .
# Expose the port the app will run on
EXPOSE 3000
CMD ["npm", "run", "dev"]
My docker-compose.yml
version: "3"
services:
frontend:
build: ./
ports:
- 3000:3000
restart: always
volumes:
- ./:/app
- /app/node_modules