Docker Installation of Node.js
Node.js is a JavaScript runtime environment based on the Chrome V8 engine, serving as a platform for running JavaScript on the server side.
1. Check Available Node Versions
Visit the Node image repository address: https://hub.docker.com/_/node?tab=tags.
You can view other versions of Node by sorting with "Sort by", with the default being the latest version node:latest.
You can also find other versions you want in the dropdown list:
Additionally, we can use the docker search node
command to check available versions:
$ docker search node
2. Pull the Latest Node Image
Here, we pull the official latest version of the image:
$ docker pull node:latest
3. Check Local Images
Use the following command to see if the node image is installed:
$ docker images
From the image above, we can see that the latest version (latest) of the node image is installed.
4. Run the Container
After installation, we can use the following command to run the node container:
$ docker run -itd --name node-test node
Parameter explanation:
- --name node-test: Container name.
5. Installation Successful
Finally, enter the container to check the node version:
$ docker exec -it node-test /bin/bash
root@6c5d265c68a6:/# node -v