npm init
npm install express --save
index.js
var express = require('express')
var app = express()
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function (req, res) {
res.send('hello world')
})
app.listen(8081, function(){
console.log("app listen on port 8081")
})
Dockerfile
FROM node:9.3.0-alpine
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD node index.js
EXPOSE 8082
run
docker build -t dockernode .
docker run -it --rm -p 8081:8081 dockernode