Docker 101

In this introductory article, I will briefly discuss what is Docker, how does it work and what are its benefits.

· 4 min read

If you are an active developer or someone working in software development field in 2023, there is no way you haven't heard about Docker. Docker has become an essential tool for software development and deployment. It is an open-source platform that simplifies the process of creating, deploying, and running applications in containers. With Docker, developers can package their applications with all of their dependencies, ensuring that they can be easily moved between environments, from development to production.

In this article I will briefly discuss what is Docker, how does it work, its components and its benefits.

What are containers?

Before we dive into Docker, we need to understand something called containers. Containers are lightweight, stand-alone executable packages that contain everything an application needs to run, including code, libraries, dependencies, and configurations. They provide a lightweight and efficient way to deploy and manage applications, as they enable developers to create consistent environments that can run on any machine, regardless of the underlying infrastructure. Containers offer several benefits, including faster deployment, improved scalability, and easier management, making them a popular choice for modern application development and deployment.

What is Docker?

Docker is an open-source platform that uses containerization to enable the creation and deployment of applications in a lightweight and portable manner. Docker allows developers to package their applications and dependencies into isolated environments known as Docker images. These images can be run on any system with Docker installed, making it easy to move and run applications between development, testing, and production environments.

How does Docker work?

Docker is composed of several components that work together to enable containerization and container management. These components include:

  1. Docker Engine - This is the core component of Docker that runs and manages containers. It is responsible for building, running, and distributing Docker images.
  2. Docker CLI - This is the command-line interface for Docker that allows users to interact with Docker Engine and perform various operations on containers, images, volumes, and networks (Docker volumes and networks are out of scope for this intro article).
  3. Docker Compose - This is a tool for defining and running multi-container Docker applications. Docker Compose allows users to define a set of services, networks, and volumes in a single file, and then deploy and manage them using simple CLI commands.
  4. Docker Hub - This is the official Docker image registry that allows users to store, share, and download Docker images. Docker Hub is also used to manage repositories and access controls for images. There are several other registry services offered by different providers such as ACR by Azure, ECR by AWS, GCR by GCP, GitHub Packages, Red Hat Quay and many more.

Overall, these components (+ few more) work together to provide a powerful and flexible platform for containerization and container management.

Docker uses a client-server architecture to provide a platform for containerization. The Docker client interacts with the Docker daemon, which is responsible for building, running, and managing Docker containers. A base for docker containers is Docker image. Docker images are built using a Dockerfile, which is a text file that specifies the instructions for building the image. A typical Dockerfile defines the base image, sets up the environment, installs dependencies, and copies the application code into the container. Docker images are stored in a registry, which can be Docker Hub or any other private/public registry or local.

To run a Docker container, the user starts the container from an image. Docker creates a new container based on the image, which runs in an isolated environment with its own filesystem, network, and resources. Multiple containers can run on the same host, and each container has its own isolated environment. Docker uses a layered filesystem and copy-on-write strategy, which means that multiple containers can share the same base image while still allowing for customization of the container's filesystem. This allows for efficient use of resources and minimizes the duplication of data.

Getting Started

To get started with Docker, you will need to install Docker on your system. Docker is available for Windows, Mac, and Linux systems, and can be downloaded from the Docker website:

Once you have Docker installed, you can use the Docker CLI or Docker Desktop to create, manage, and run containers. Docker provides a range of commands for working with containers, including:

docker run - This command is used to create and start a new container.
docker stop - This command is used to stop a running container.
docker ps - This command is used to list all running containers.
docker images - This command is used to list all available images on your system.
docker build - This command is used to build a new image from a Dockerfile.

These are just a few most popular commands and there are several more.

Benefits of Docker

Docker is a widely used tool in modern software development world. It helps to streamline software development and deployment processes, making it a popular tool in the DevOps community. It offers several benefits that remove the burden with classical software development and deployment strategies. Some of them are:

  1. Portability: Docker containers can run on any system that has Docker installed, making it easy to move applications between development, testing, and production environments.
  2. Scalability: Docker allows developers to scale their applications quickly and easily by replicating containers as needed.
  3. Consistency: Docker ensures that applications run consistently across different environments, minimizing the risk of configuration errors and other issues.
  4. Isolation: Docker containers provide a secure and isolated environment for applications, preventing conflicts between different applications and dependencies.
  5. Efficiency: Docker's containerization approach allows developers to package only the necessary components of an application, reducing the size and complexity of the overall application.

In conclusion, Docker is a powerful platform for containerization that allows developers to package their applications and dependencies into isolated environments. With Docker, developers can streamline their software development and deployment processes with ease. Understanding the components and workings of Docker is essential for developers looking to leverage its benefits and streamline their workflows.

So, if you are a developer, I know you have three years of experience in each of over 400 JavaScript frameworks. But have you ever played around with Docker? Or is containerization just too mainstream for you?