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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Low-Code Development: Leverage low and no code to streamline your workflow so that you can focus on higher priorities.

DZone Security Research: Tell us your top security strategies in 2024, influence our research, and enter for a chance to win $!

Launch your software development career: Dive head first into the SDLC and learn how to build high-quality software and teams.

Open Source Migration Practices and Patterns: Explore key traits of migrating open-source software and its impact on software development.

Related

  • 7 Ways of Containerizing Your Node.js Application
  • Deploy an Application for Azure Container Registry
  • How to Setup MuleSoft Runtime Fabric on Self-Managed Kubernetes With AKS
  • AppOps with Kubernetes and Devtron - The Perfect Fit

Trending

  • Benchmarking Java Streams
  • Leveraging Test Containers With Docker for Efficient Unit Testing
  • 7 Linux Commands and Tips to Improve Productivity
  • Machine Learning With Python: Data Preprocessing Techniques
  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.

By 
Charles Ituah user avatar
Charles Ituah
·
May. 17, 23 · Tutorial
Like (1)
Save
Tweet
Share
3.7K 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.

Related

  • 7 Ways of Containerizing Your Node.js Application
  • Deploy an Application for Azure Container Registry
  • How to Setup MuleSoft Runtime Fabric on Self-Managed Kubernetes With AKS
  • AppOps with Kubernetes and Devtron - The Perfect Fit

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: