I have the problem with installing node_modules
inside the Docker container and synchronize them with the host. My Docker\'s version is 18.03.1-ce, build
There's three things going on here:
docker build
or docker-compose build
, your Dockerfile builds a new image containing a /usr/src/app/node_modules
directory and a Node installation, but nothing else. In particular, your application isn't in the built image.docker-compose up
, the volumes: ['./app/frontend:/usr/src/app']
directive hides whatever was in /usr/src/app
and mounts host system content on top of it.volumes: ['frontend-node-modules:/usr/src/app/node_modules']
directive mounts the named volume on top of the node_modules
tree, hiding the corresponding host system directory.If you were to launch another container and attach the named volume to it, I expect you'd see the node_modules
tree there. For what you're describing you just don't want the named volume: delete the second line from the volumes:
block and the volumes:
section at the end of the docker-compose.yml
file.