Containerize a Node.js Application

Learn how to package a Node.js (TypeScript) back-end application in a Docker container.

This tutorial assumes you have some experience building Node.js applications, so it will concentrate on how to Dockerize a TypeScript-based Node.js application.

We start by building a simple web application with the express framework, then we create a Docker image for it, and finally, we launch a container from that image.

There are three essential files for this tutorial:

  • main.ts
  • package.json
  • Dockerfile

The main.ts file contains the Node.js application’s code. It’s a simple application that, when accessed, prints hello-world to our browser:

Get hands-on with 1400+ tech skills courses.