DEV Community

Abhinav Pandey
Abhinav Pandey

Posted on

4 1

What is Containerization?

Introduction

Containerization is a way to create, package and distribute software across different environments.
It is a virtualization technology which allows you to create a container image that can be used to run a software application on a different host.

The basics and terminology

Container images - are a collection of files required to run the software application.
It may contain a binary executable, a configuration file, a database, a log file, a script, a shell script, a web server, etc.

Containers - are the actual running software applications which are created from the container images.

Daemon

A process that runs in the background and manages the containers.
You can think of it as a light-weight layer that abstracts the underlying OS.

The process of starting a container is as follows:

  1. Choose a container image
  2. Check if the image exists
  3. If the image exists, create a container from the image
  4. If the image does not exist, download the image from the internet and then create a container from the image.
  5. Start the container

Container repository

A repository where you can store and share container images. For example, Docker Hub.
This is similar to a repository on GitHub.

The features of a container repository are:

  1. You can store and share container images
  2. You can create a repository
  3. You can push and pull container images
  4. You can create tags/versions for container images
  5. You can include a description for the container image - similar to a readme file.

Docker

Docker is a containerization technology. It is the industry standard containerization tool. It is used to create, package and distribute software across different environments.

Dockerfile

It is a file that contains instructions for building a container image. If you wanted to create your own container image, you would create a Dockerfile with instructions for building the image.

Let's look at a simple example of a Dockerfile:

FROM node:latest
COPY . /app
RUN npm install
CMD ["npm", "start"]
Enter fullscreen mode Exit fullscreen mode

Let's look at each step now:

  1. FROM - This is the base image from which the container image is created. node is the base image for Node.js. It contains the Node.js runtime and the Node.js package manager.
  2. COPY - This copies the files from the current directory to the container image.
  3. RUN - This runs the commands in the container image. This will be done when the container image is created.
  4. CMD - This is the command that is executed when the container is run.

The base image - is built on top of an OS image but not the complete OS.

A complete OS image would include

  • the OS kernel - the core of the OS and is responsible for the basic system functions like booting, starting, stopping, and managing system resources.
  • the OS distribution - the software that is installed on the kernel.

Container images do not include the OS kernel because those responsibilities are handled by the daemon. This makes the container image lighter than virtual machine images.

When you run a container created from this container image, it will run the command npm start which will start the Node.js application.


Thanks for reading!

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay