Docker npm install + persistence

Hi Together,

I have some question about docker and it's persistence especially for packages I installed with npm install.

After reading the documentation several times I wanted to ask if I understand it correctly.

  • You can use /data for data persistence and to either a bind mount or a volume. But that's only for the flows not for the packages.
  • If you need to install other stuff with npm install it wont be persistent if you update the container with
    docker pull ...
    docker stop ...
    docker rm ...
    docker run ....
  • To install additional npm packages you have to clone the repo from github and use the docker-costum scripts ( and modify the package.json with all the aditional npm packages I need) ... otherwise you'll always loose the npm packages that you installed afterwards using docker exec -it bash ... npm install ....

Am I getting right all these points?
What is the reason that the npm packages are not presistent? Is it about haveing less complications with outdated packages when updating the docker container?

Thanks for your feedback.

Regards

Stefan

The idea behind any docker container is that it is delivered in a "working" condition and a known state at any point in time.

By using the Docker Build process you are able to customise a basic container and add anything to it that you require

You could if you wished rebuild the container to better suit your needs by having things such as the NPM store put into persistent storage (as per the flows) - but this to a certain extent is not the philosophy behind the design of docker containers

Craig

1 Like

Nope - your assumption 2 is incorrect... If you have set up persistence then /data will include any node_modules that you have subsequently installed - so will survive. So no you don't need to clone anything unless you want to and want to pre-build them in,

1 Like

@dceejay Thanks for pointing that out ... Found the problem ... I just missed: cd /data ... as described in the documentation.

Thanks