The goal of this article is to show how to get a Node.js application into a Docker container.
Setting up Node app
Create a directory and run the command npm init to initialize the app and install initial dependencies
Create a file app.js and write this code inside it.
The next step is to add Docker to it. So, create an empty file named Dockerfile and put this code inside it
Now add .dockerignore file to prevent your local modules and logs to be copied onto your Docker image and add this two files
Now we need to build our Docker image and run it. This can be done by the following command :
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Nodejs – Connect Mysql with Node app
- NodeJS | Building simple REST API in express
- Introduction to Xamarin | A Software for Mobile App Development and App Creation
- Deploying Your Web App using Azure App Service
- Progressive Web App - A Combination of Native and Web App
- Cowsay in Nodejs using Requests library
- Nodejs | Web Crawling using Cheerio
- Web-Socket in NodeJS
- Signup Form Using Nodejs and MongoDB
- Nodejs | DNS
- Encrypting Data in NodeJS
- Difference between NodeJS and AngularJS
- Nodejs | Jimp
- Nodejs | DNS | setServers()
- NodeJs - Handling invalid routes
- Nodejs | authentication using Passportjs and passport-local-mongoose
- Nodejs | GM charcoal() Function
- Nodejs | GM blur() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.