Docker Setting Node.js
We will now see the different steps for getting the Docker container for Node.js ready.
Step 1 − The initial step is to pull the image from Docker Hub.Whenever you sign into Docker Hub, you will actually want to search and seethe image for Node.js as shown below. Simply type in Node in the search boxand click on the node (official>
link which comes up in the search results.

Step 2 − You will see that the Docker pull command for node in the details of the repository in Docker Hub.

Step 3−On the Docker Host, use the Docker pull command as shown above to download the most recent node image from Docker Hub.

When the pull is finished, we can then continue with the next step.

Step 4 − On the Docker Host, how about we use the vim editor and create one Node.js example file. In this file, we will add a simple command to show "HelloWorld" to the command prompt.

In the Node.js file, we should add the following statement−
Console.log(‘Hello World’>
;
This will output the "Hello World" phrase when we run it through Node.js.

Ensure that you save the file and then continue to the next step.
Step 5 − To run our Node.js script using the Node Docker container, we want to execute the following statement−
sudo docker run –it –rm –name = HelloWorld –v “$PWD”:/usr/src/app
–w /usr/src/app node node HelloWorld.js
The following points should be noted about the above command −
We will then, at that point, get the following result. And , from the result, we can clearly see that the Node container ran as a container and executed the HelloWorld.js script.
