0

When I perform a npm install -g in a Docker container, will it only affect the container or will it actually install the package on the host of the container?

Regards.

TanguyB
  • 1,954
  • 3
  • 21
  • 40

2 Answers2

1

You can assume, for most cases, it will affect only the container, unless you map your npm global directory as a volume from the host to the container at run command, for example:

docker run [...] -v /usr/lib/node_modules/:/usr/lib/ [...]

Webert Lima
  • 13,197
  • 1
  • 11
  • 24
  • Hi! Thanks for the answer, and I won't be doing that as I just need a couple of packages to serve some static files in the container. Thanks for the answer! – TanguyB Jan 26 '17 at 16:11
1

Everything that you run inside a docker will affect only the container, that will affect the host only if you explicit mount the host dir on the docker.

Doing something like that: docker run [...] -v /home/youruser/wwwtest:/wwwtest In this example you will run the npm install on wwwtest of the docker and will affect the local dir /home/youruser/wwwtest.

But like I said, only if you've used this option.

BigLeo
  • 6,906
  • 2
  • 13
  • 12