Habilelabs-Logo
Blog

Getting started nodejs project using docker on windows

February 23rd, 2017 . 2 minutes read
Blog featured image

We will study how to get started with node js project using Docker. First of all, let’s start with Docker.

What is Docker?

Using docker with node,js, getting started with node and docker

Getting started with Docker and node.js, Use node.js with docker, how to use node.js with docker, docker and node.js,

It has significantly improved the way we build, ship and run apps. Let assume you have multiple team member and some else join your team then to start with this you need to install everything on his machine. later on, you realized that his version of node.js is different. By using docker we can ensure we use the same environment on every machine.  Read this tutorial to learn how to integrate Docker with your Node.js application.

Create a Simple Node.js Application:

Create a simple node.js app to getting started. First, create a folder for the project and create a package.json file in this.

Create a simple server,js file

 

Creating a Dockerfile

Create a file with name Dockerfile.

Dockefile should look like this

In this, we are using node boron stable release.

Application will run on 8080 port inside the docker,

Building your image:

-t flag allows you tag your image, This is helpful so later you can find a correct image using the tag.

After building image you can list your image using

 

Run the image

Running your image with -d runs the container in detached mode, leaving the container running in the background. The -p flag redirects a public port to a private port inside the container. Port 5000 of your machine will be bound to internal 8080 port.

you can check your app running by using localhost:5000 in your browser.

Conclusion:

Improve your app building, shipping and running with Docker Node js.  You can connect with us if you need consultancy on Node js. Know what are the common mistakes a node js developer makes!

Hope you enjoy this post, if you have any query then let me know in your comments.

Share this with your friends if you find it helpful.

Author: morwal89
Share: