Serving a node application in Docker is actually fairly simply. In this post, we’ll do so using only a six-line Dockerfile!

Create a Sample App

For our proof-of-concept, we’ll create a sample node app in a new directory. Let’s quickly put one together.

Create app directory

First create a node-in-docker directory and cd into it.

mkdir node-in-docker
cd node-in-docker

initialize npm project with defaults

Next, initialize an npm project. The -y flag will initilize with default settings.

npm init -y

#node #nodejs #docker

How to Serve a Node App in Docker
11.85 GEEK