I tried to run npm ci
command using the same package.json
and package-lock.json
files in three different environments:
- docker host machine - takes ~27s to complete
- inside a docker container - takes ~32s to complete
- during building a docker image - takes ~163s to complete
I wonder why it takes much more time to install packages when building an image. What the difference between running commands when building an image and when running commands inside a container manually? Perhaps it's related to the amount of resources (CPU, Memory) docker uses when building an image?
I use the same node and npm version in all three environments. Docker host is a Windows Server 2019 VM that has 2 virtual CPUs and 2GB of memory. Docker version is 18.09.2
.