Creating a Docker container for a NodeJs application

This is a simple Docker tutorial for creating your first NodeJs container, above is the vid and below you will find the steps followed.


  • Pre-reqs
  • Create an incredibly simple node app
  • Create your first container 
  • Build and Run your new container

Create your simple node app

Create a dockerfile

  • Include container with node preinstalled: 
    • FROM node
  • Create default/working directory: 
    • WORKDIR /usr/src/app
  • Copy package.json to workdir and install dependencies (not really needed for this app but you might need it😊):  
    • COPY package.json .
    • RUN npm install
  • Copy the rest of the app (just the index.js file in this case)
    • COPY . .
  • Add a command to run when this container is started
    • CMD ["node", "index.js"]

Build & Run

  • Build the container:
    • docker build -t my-node-app .
  •  Run the container
    • docker run my-node-app


Dockerizing a Node.js web app

Entradas populares de este blog

Creating a Docker container for a NodeJs application: Express + Mongo + Docker Compose

How to organize your clientlibs JavaScript files by Integrating Adobe Experience Manager and System.Js

Creating a Mongo replicaset using docker: Mongo replicaset + Nodejs + Docker Compose