English

Docker Container

Posted on Mar 29, 2024 by
72

What Is Docker Container?

Docker is an open-source application container engine that utilizes lightweight virtualization technology to efficiently package applications into portable containers.

The Significance of Docker

Virtual machine (VM) technology is employed by enterprises to reduce their reliance on physical hardware resources. This technology virtualizes a physical device into multiple logical devices, each capable of running different operating systems. The beauty of VMs lies in their ability to allow applications to operate independently, without interference from one another. Consequently, the operational efficiency of devices is greatly enhanced. However, VMs require the installation of complete operating systems, resulting in substantial resource consumption. In many instances, users only necessitate the execution of simple applications. VM technology, with its complexity and resource waste, is not an optimal solution. Therefore, there is a pressing demand for a lightweight virtualization technology.

Containers, a lightweight virtualization technology akin to VMs, provide isolated environments. Unlike VMs, which conduct resource isolation at the operating system level, container technology performs system isolation at the process level. Docker, being a prominent tool for creating containers, has experienced rapid development in recent years. It enables developers to package various applications and their dependencies into Docker images, which can then be installed and executed on any physical device, be it Linux or Windows. Docker achieves virtualization, decoupling applications from the underlying devices and allowing for flexible deployment and migration across physical devices. This liberates operations and maintenance (O&M) engineers from the complexity of environment deployment, significantly enhancing work efficiency, and mitigating deployment risks.

Docker containers possess the following attributes:

  • Lightweight: Docker allows for the efficient utilization of computing resources by enabling multiple containers to share the host machine's operating system kernel. This results in quick container startup times and minimal utilization of computing and memory resources.

  • Platform Agnostic: Docker containers adhere to open standards and can run seamlessly on popular Linux and Microsoft Windows systems. They are compatible with various infrastructures, including virtual machines, bare metal servers, and cloud environments.

  • Secure and Reliable: Docker provides a robust security framework by isolating applications within containers and decoupling them from the underlying infrastructure. This default isolation ensures that if an application within a container encounters an issue, only that container is affected, while the host machine remains unaffected.

Differences Between Docker Containers and VMs

Docker containers and VM technologies (VMs) differ in their underlying technologies and operational characteristics. The illustration below depicts the logical structure of both VMs and Docker containers.

VMs:

  • Utilize a hypervisor-based platform to manage the operating system running on them.

  • Each VM requires its own complete operating system, applications, and dependencies.

  • Virtualization at the hardware level allows VMs to run multiple instances of different operating systems.

  • VMs have a relatively higher resource footprint due to the need for separate operating systems.

  • VMs typically take longer to start or stop compared to Docker containers.

  • Each VM runs in its isolated user space, ensuring strong isolation between instances.

Docker Containers:

  • Use the Docker engine for resource scheduling and isolation, resulting in improved resource utilization.

  • Containers share the host machine's operating system, reducing overhead and resource requirements.

  • Multiple container instances can run concurrently on the same hardware, surpassing the scalability of VMs.

  • Containers can be started or stopped within seconds, providing faster deployment and scaling.

  • Docker containers leverage application images, which can be obtained, updated, and version-controlled, akin to Git operations.

  • Dockerfiles enable the automatic creation and flexible deployment of containers, enhancing operational efficiency.

Docker containers focus primarily on running applications and do not impose significant system resource overhead beyond that. This ensures optimal application performance while minimizing system resource consumption.

The comparison between Docker containers and VMs is depicted in the following diagram.

Operational Mechanism of Docker Container

Docker comprises the following components:

  • Image: A Docker image is a specialized file system that contains program files, registries, resources, and configuration files necessary for running containers. It also includes specific configuration parameters required during execution. Docker images are static and do not change once built. They serve as templates for creating Docker containers. Multiple containers with the same configuration can be created from a single image.

  • Container: A Docker container is a runnable instance of an image. It utilizes containers to execute applications. Each container operates in an isolated and secure environment, akin to a lightweight Linux runtime environment. Containers provide the necessary runtime environment for applications to run consistently across different systems.

  • Image registry: Docker images are stored in image registries, which can be either public or private repositories. Once an image is created, it can be uploaded to a registry. To use the image on another host machine, it can be downloaded from the registry. Registries allow for easy sharing, distribution, and retrieval of Docker images across different environments.

The Docker operating logic is depicted in the following graphic. The Docker daemon serves as the server, responsible for receiving requests from the Docker client. It handles tasks such as building, running, and distributing Docker containers. The Docker daemon operates on a Docker host machine, where it manages the containers and their associated resources. The Docker client connects directly to the Docker daemon, allowing for seamless communication and interaction between the client and server components.

The Docker architecture involves the following key roles:

1. Docker client: A Docker client is a program or interface that communicates with the Docker daemon. It sends requests, such as docker build, docker pull, and docker run commands, to the Docker server or daemon. The Docker client initiates actions and interacts with the Docker daemon to perform various tasks. For example, it can request the building of an image by sending a docker build command or pull an image from a remote registry using the docker pull command. The client receives the results or responses from the daemon.

  • The orange dotted line represents the Docker daemon executing the docker build command received from the Docker client. It builds an image based on the instructions provided in the Dockerfile and stores the resulting image on the local Docker host machine.

  • The blue dotted line represents the Docker daemon executing the docker pull command received from the Docker client. It retrieves images from a remote image registry and stores them on the local Docker host machine. It can also push local images to a remote registry.

  • The black dotted line represents the Docker daemon executing the docker run command received from the Docker client. It installs an image into a container and starts the container for execution.

2. Docker host machine: The Docker host machine refers to a physical or virtual machine where Docker daemons and containers run. It provides the runtime environment for Docker operations and hosts the containers created from Docker images. The host machine manages resources and runs the Docker daemon.

3. Docker daemon: The Docker daemon receives and processes requests from Docker clients. It listens for Docker API requests and interacts with the Docker client. The daemon manages Docker objects such as images, containers, networks, and data volumes. It performs tasks like building images, pulling/pushing images from/to registries, and running containers. The Docker daemon ensures the proper execution and management of Docker containers and their associated resources.

These roles collaborate to facilitate communication, efficient management, and flexible deployment of Docker containers within the Docker architecture.

Tags

You might be interested in

See profile for undefined.
FS Official
AI Firewall
See profile for undefined.
FS Official
VPN
See profile for undefined.
FS Official
VPC