Docker makes v3 named volume & node_modules from npm install

Using compose v3.

In the assembly, I copy package.json and run npm install in

/var/www/project/node_modules

I do not add code at the build stage.

In the essay I add volumes

- ./www:/var/www/project/www

As you know, binding the host to / www will effectively overwrite the node_modules that I installed during the build phase.

That's why we add a named module afterwards

- ./www:/var/www/project/www
- modules:/var/www/project/www/node_modules

this works fine and dandy the first time we build / launch a project

since named volumes "modules" do not exist, www / node_modules will be mounted instead from the build stage.

HOWEVER , this is a pressing issue.

The next time I made changes to package.json and would do:

docker-compose up --build 

, npm, , "" ( ), "" .

node. , , .

, package.json, , , .

+4
1

rm script node npm install.

$ docker system prune . , .

0

Source: https://habr.com/ru/post/1675329/


All Articles