DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Competing Consumers With Spring Boot and Hazelcast
  • Microservices With Apache Camel and Quarkus (Part 3)
  • Health Check Response Format for HTTP APIs
  • Step Into Serverless Computing

Trending

  • Competing Consumers With Spring Boot and Hazelcast
  • Microservices With Apache Camel and Quarkus (Part 3)
  • Health Check Response Format for HTTP APIs
  • Step Into Serverless Computing
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How To Use the Node Docker Official Image

How To Use the Node Docker Official Image

A step-by-step tutorial on how to create a Docker container using the official image of Node that will make your work process easier and more productive.

Charles Ituah user avatar by
Charles Ituah
·
May. 17, 23 · Tutorial
Like (1)
Save
Tweet
Share
2.94K Views

Join the DZone community and get the full member experience.

Join For Free

What Is Node.js?

Node.js, which is a crucial component of the MERN stack, has continued to expand in popularity and has topped Stack Overflow's list of the most popular web frameworks and technologies for 2022. Since Node.js applications are written in JavaScript, which is the world's leading programming language, many developers will find it easy to use. To address common development challenges and to cater to the popularity of Node.js, we introduced the Node Docker Official Image (DOI). 

What Is the Node Docker Official Image?

The Node Docker Official Image comes with all the necessary components, including source code, core dependencies, tools, and libraries, to ensure that your application runs smoothly. It is designed to support various CPU architectures such as amd64, arm32v6, arm32v7, arm64v8, ppc641le, and s390x. Additionally, you have the freedom to select different tags or image versions for your project. Opting for a specific version like node:19.0.0-slim ensures that you use a stable and efficient version of Node.js. 

How To Run Node in Docker

To begin with, you should download and install your preferred Docker Desktop release. Docker Desktop comprises the Docker CLI, Docker Compose, and other essential development tools. Moreover, the Docker Dashboard, which is the UI component of Docker Desktop, will assist you in managing containers and images.

Enter a Quick Pull Command

Pulling the Node DOI is the quickest way to begin. Enter this command in your terminal.

Dockerfile
 
docker pull node


This grabs the default latest Node version from Docker Hub. You can readily use this tag for testing or local development. 

After the CLI completes the task, it will show a status message. Additionally, you can verify this by going to Docker Desktop. To do this, navigate to the Images tab on the left sidebar and look through the list of images. Your node image will be displayed by Docker Desktop. 

Confirm That Node Is Functional and Working

Are you interested in running your newly created image as a container? If so, simply hover over the listed node image and click on the blue "Run" button. Once you do this, your Node container will generate basic log entries and operate continuously in case any requests are received. 

Create Your Node Image From a Dockerfile

By building from a Dockerfile, you can have complete authority over the composition and configuration of your image, as well as your overall application. Nevertheless, Node has minimal requirements for proper functioning. To help you get started and running, here is a Dockerfile that is stripped down (using a particular, Debian-based image version): 

Dockerfile
 
FROM node:19-bullseye


To create your image, Docker will utilize the Node version you have selected. It is recommended to opt for node:19-bullseye as it is a reliable image that caters to various use cases. Furthermore, this version is stable and safeguards you against any new disruptive modifications that can occur with the use of the latest tags.

 To build your image from a Dockerfile, run this command:

Dockerfile
 
docker build -t my-nodejs-app .


You can then run your new image by entering this command:

Dockerfile
 
docker run -it --rm --name my-running-app my-nodejs-app


Node.js application Command (computing) Docker (software)

Opinions expressed by DZone contributors are their own.

Trending

  • Competing Consumers With Spring Boot and Hazelcast
  • Microservices With Apache Camel and Quarkus (Part 3)
  • Health Check Response Format for HTTP APIs
  • Step Into Serverless Computing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: