How to install Node.JS & NPM on Docker

- Advertisment -

Node.JS and NPM on Docker work in the same as they do on any other OS or machine. The difference is docker runs it on a virtual machine. If you talk about Node.JS, it is a platform built on the Chrome JavaScript runtime and an event-driven I/O server-side JavaScript environment. Based on Google’s V8 engine, the V8 engine executes Javascript very fast and performs very well.

Here we are about to show how we can install LTS version of Node.JS which includes NPM in Docker container.

First thing you should have Docker on your system or server. You can see the tutorials to install it on Windows 10/7 and Ubuntu Linux.

Download Node.js on Docker

Just go to Docker interface and type the below Node pull command:

docker pull node:latest

The above command will install the latest version of the Node.js while writing this article it was v 12.7.0.

Run Node.js on Docker

To run Node on docker use the below

docker run -it node

Install Node JS on Docker

However, to install the current LTS version that is v10.16.1, you can use its tag.

  • tag- 10.16.1-stretch-slim  size- 55 MB
  • tag- 10.16.1-stretch size- 348 MB
  • tag- lts size- 348 MB

For that the Command will be like this:

docker pull node:10.16.1-stretch-slim
or
docker pull node:10.16.1-stretch 
or 
docker pull node:lts

So to run the 10.16.1-stretch

The command will be the:

docker run -it 10.16.1-stretch node

If you think that running docker with such a long tag name is a little bit cumbersome then give name to the image name.

For example, to run a particular version of a node when there are multiple images have been installed; we have to define a tag in a command. Thus if we have the latest version of the node along with some other version such as 10.16.1-stretch, so the command will be like this

docker run -it tag imagename

docker run -it 10.16.1-stretch node

To make it easy we can simply tag a new image name to our existing image.

Suppose we want to tag a name node10 with node:10.16.1-stretch then the command will be

docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

docker run -it node:10.16.1-stretch node10

That’s it, now you can simply run the 10.16.1-stretch of a using a simple command

docker run -it node10

For more Node.Js official Docker tags you can visit the official website of Docker.

H2S Media Team
H2S is a group of tech enthusiasts those are passionate about latest technology developments. They always like to solve own technical problems and share the same solution with others through this Website.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts

What is the seamless mode on VirtualBox? How to control host and VM using it

If you are looking for an open-source virtual Machine manager, VirtualBox is one of the best options that you...

What is GitHub? Why programmers use GitHub?

For the upcoming software developers and the existing riders, it is always hard to manage and select the right...

How to use the Save to Facebook extension to bookmark web links on Facebook

We come across different types of links while we access the internet and one of the best ways to...

Top 5 free CRM Services for New and Small Businesses

Starting a new business or a startup can be hard as climbing a mountain with a...
- Advertisement -

MagTapp app – Improve your vocabulary on Android while browsing web

Improve your English vocabulary and word meanings right on the web browser while ready different articles using...

Best 5 Free Apps to Create Bootable USB drives in 2020

Do you need to install an operating system in your Computer? Then quickly grab a CD or DVD and...
- Advertisement -

You might also likeRELATED
Recommended to you