Developing a node app in docker


We want to rapidly develop our node app inside a docker container, being able to install modules, make code changes, and see instant results. The problem is that while the official node image supports a handy onbuild feature which will grab the package.json and install everything we need, this also means having to rebuild the image every time a dependency changes.


Use this image, which places the node_modules folder one level higher, meaning it isn’t overwritten by the docker mount, and you can still mount and install your own node modules on the fly.


An easier but less obvious way to solve the problem is to specify your /usr/src/app/node_modules folder as a volume with no mapping to the host. This preservers the container copy and allows you to keep your local copy