Suppose you don’t want to install Node.js and npm on your local machine and already run your application in a Docker container. How do you install your dependencies from package.json? For deployment, the most common way is to create your own Docker image, where npm install is part of the Dockerfile. But what do you do on your development machine, where you don’t want to build a new image all the time and use the vanilla node image ? Where you want to create a node_modules directory inside your project directory, with the correct permissions? Jump to the end of the article to get a solution, or follow me on my journey …

First try: running as root

Second try: running as unprivileged user

Third try: running as the current user

Finally, permission nirvana

#docker

Run Npm install As Non-root From A Docker Container
4.85 GEEK