Almost all tutorials shows how to initialize a node app with Node installed locally. Here is a way to create a node app in Docker without installing Node locally.
Initialize a node app in the current directory with Docker:
- Replace npm initwith whatever npm command is needed
docker run --rm -v "$PWD:/$(basename $PWD)" -w "/$(basename $PWD)" -it node:current-alpine sh -c "npm init"
Info
- 
-rmremove
- 
-vvolume
- 
$PWDpath to current directory
- 
basenamelast element of file path
- 
-wworking directory
- 
-itinteractive docker terminal
- 
-ccontext, without it sh will not work
 

 
    
Top comments (0)