Docker-compose: node_modules mouting as volume

  docker, docker-compose, dockerfile

I have an app with the following services:

  • cockpit/ – use as a headless CMS service.
  • frontend/ – bootstrapped by Create React App.

I have a question about frontend

frontend/Dockerfile

FROM node:12.16.3-alpine

RUN mkdir -p /app
WORKDIR /app

COPY package.json yarn.lock /app/

RUN yarn install --pure-lockfile
COPY . /app

CMD ["yarn", "run", "start"]

docker-compose.yml

    frontend:
        ...
        volumes:
            - ./frontend:/app
            - /app/node_modules

The question is /app/node_modules is same meaning with ./frontend/node_modules:/app/node_modules ?

If not, what is the difference?

Source: Docker Questions

LEAVE A COMMENT