Part 1 : Running nodejs app (welcomeapp) on Docker Containers

Goal :

The main goal of this blog post and next few upcoming blog posts are to build a simple nodejs webapp and run them in azure container service and orchestrator Kubernetes.


You already know the basics of Nodejs and docker.


Docker installed on the local machine. you can verify by running below command

docker --version

output will be something similar to this

Docker version 18.09.0-ce-beta1, build 78a6bdb

This will help you to get upto speed .. Docker_CheatSheet_08.09.2016_0

Follow the steps…

We are going to build a simple welcomeapp in Node JS.

Create the pakage.json

  "name": "welcome_app",
  "version": "1.0.0",
  "description": "welcome app Node.js on Docker",
  "author": "ManiMaran Chandrasekaran<>",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  "dependencies": {
    "express": "^4.16.1"

Create the server.js

'use strict';

const express = require('express');
const PORT = 8080;
const HOST = '';

// App
const app = express();
app.get('/', (req, res) => {
  res.send('I am the Welcome app, used for the demo\n');

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

Create the .dockerfile

FROM node:carbon

# Create app directory
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .

CMD [ "npm", "start" ]

Now, its time to build the image and test our welcomeapp running in the docker container.

#List the current available images

docker images

# Build the current docker file

docker build -t mani0070/welcomeapp .

# run the docker image 

docker run -p 32432:8080 mani0070/welcomeapp

#connect to the container

curl http://localhost:32432

if you see the below message then you have successfully created a node js app running on a docker container

I am the Welcome app, used for the demo

docker ps

you will see all the container running on the host (in this case its your local machine).

docker exec -it <containerid_from_abovestep> ls /bin

you can start listing directory

All the above files are available in the following git repo


Keep watching the space for the next post about ACR, ACS and Kubernetes



2 thoughts on “Part 1 : Running nodejs app (welcomeapp) on Docker Containers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.