How to containerize a Node.js application
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

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