Skip to main content

Command Palette

Search for a command to run...

How to containerize a Node.js application

Published
1 min read
How to containerize a Node.js application
C

Hi there! 👋 I'm Daniel Ozoemena, a passionate Cloud Solution Architect and DevOps Engineer dedicated to building scalable, secure, and innovative cloud solutions. With hands-on experience in Azure, AWS, and Google Cloud Platform, I specialize in deploying infrastructure as code, automating workflows, and optimizing system reliability. Driven by a love for problem-solving, I constantly explore new technologies and best practices to deliver impactful results. Beyond the cloud, I enjoy mentoring, blogging about tech insights, and contributing to open-source projects. When I'm not automating deployments or creating secure virtual networks, you can find me playing chess, learning about AI, or brainstorming solutions to real-world challenges. Let’s connect and grow together on this tech journey! 🚀

Get the sample application

To get started, clone the sample application provided for this guide. Open a terminal, navigate to your preferred working directory, and run the following command to clone the repository:

git clone https://github.com/docker/docker-nodejs-sample && cd docker-nodejs-sample

Initialize Docker assets

Navigate to the docker-nodejs-sample directory and run the docker init command in your terminal. The Docker init command provides default configurations, but you’ll need to answer a few questions about your application. Use the example below as a reference to respond to the prompts from Docker init, ensuring your answers match those provided.

The following content should be in your docker-nodejs-sample directory:

Run the application

Inside the docker-nodejs-sample directory, run the following command in a terminal.

docker compose up --build

  • Press v to view in Docker Desktop and click 3000:3000.

    You should see a simple todo application.

  • In the terminal, run the following command to stop the application.

docker compose down

Thanks for staying till the end

More from this blog

Everything Cloud Solution

49 posts