DEV Community

Bryan
Bryan

Posted on • Originally published at devlogbook.com

10

Create Node app using Docker without installing Node Locally

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 init with whatever npm command is needed
docker run --rm -v "$PWD:/$(basename $PWD)" -w "/$(basename $PWD)" -it node:current-alpine sh -c "npm init"
Enter fullscreen mode Exit fullscreen mode

Info

  • -rm remove
  • -v volume
  • $PWD path to current directory
  • basename last element of file path
  • -w working directory
  • -it interactive docker terminal
  • -c context, without it sh will not work

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay