DEV Community

Cover image for How to Containerize an Application.
SUBAIR NURUDEEN ADEWALE
SUBAIR NURUDEEN ADEWALE

Posted on

How to Containerize an Application.

Introduction

In today’s software development landscape, containerization has become an essential practice for building, deploying, and managing applications efficiently. This project focuses on containerizing a simple Node.js Todo List Manager application using Docker. By packaging the application and its dependencies into a container, developers can ensure consistency across different environments, simplify deployment, and improve scalability. Whether you're new to Docker or just getting started with containerization, this project offers a hands-on experience that demonstrates how to move an application from a local environment to a portable, containerized setup.

Prerequisites

Before you begin, ensure you have the following installed and set up on your system:

  • Docker Desktop (latest version) – to build, run, and manage containers.
  • Git client – to clone the project repository and manage source control.
  • An IDE or text editor – such as Visual Studio Code, for editing and managing project files.
  • (Optional but recommended) Basic understanding of terminal or command-line operations.

Step 1 : Get the app

  • Steps to Get the App and Run it in Visual Studio Code
  • Open Visual Studio Code
  • Launch VS Code on your computer.

  • Open the Terminal
  • Click on Terminal at the top menu and select new terminal

  • Clone the Application Repository
  • In the terminal, type the following command and press Enter:

git clone https://github.com/docker/getting-started-app.git

  • Navigate into the App Folder cd getting-started-app
  • Open the Folder in VS Code (Optional) code .

  • View the contents of the cloned repository. You should see the following files and sub-directories.

Step 2 : Build image

To build the image, you'll need to use a Dockerfile. A Dockerfile is simply a text-based file with no file extension that contains a script of instructions. Docker uses this script to build a container image.

  • In the getting-started-app directory, the same location as the package.json file, create a file named Dockerfile with the following contents:

  • This Dockerfile starts off with a node:lts-alpine base image, a light-weight Linux image that comes with Node.js and the Yarn package manager pre-installed. It copies all of the source code into the image, installs the necessary dependencies, and starts the application.

  • Build the image using the following commands:

docker build -t getting-started-app .

Step 3: Start an app container

  • Now that you have an image, you can run the application in a container using the docker run command.
  • Run your container using the docker run command and specify the name of the image you just created:

** docker run -d -p 127.0.0.1:3000:3000 getting-started**

Conclusion

By the end of this project, you will have successfully transformed a simple Node.js Todo List Manager into a fully containerized application. You’ll gain hands-on experience with Docker commands, image creation, and container management — valuable skills for modern DevOps and cloud-based development workflows. This exercise not only strengthens your understanding of containerization but also prepares you to deploy scalable, portable, and efficient applications in real-world environments.

Top comments (0)