TL;DR Use the following code snippet (or a variation) after all your app dependencies but before you ADD your app code to the container… this way you don’t rebuild your modules each time you re-build your container. If your package.json file changes then your modules will be rebuilt. See this gist for a full example. Add this to your Dockerfile, after your deps, but before your app code.gist 1 2 3