Open In App

What Is Docker Daemon ?

Last Updated : 16 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Docker is synonymous with containerization, yet it is just one of the many implementations of the Open Container Initiative (OCI). As the most widely embraced containerization platform, Docker has greatly streamlined the development and deployment of modern applications. At the core of Docker’s operation is the Docker daemon, an underlying background service running on the host OS, responsible for executing all Docker tasks.

In this article, we will be covering understanding its key functions, Integration with other docker components, and some basic configuration

What is Docker’s daemon?

At the very core of Docker‘s operation lies the Docker daemon. It is the service responsible for orchestrating container lifecycle management. It means that the docker daemon handles various tasks including container creation, execution, and monitoring. In a nutshell, it acts as a bridge between the Docker client and the Docker engine following Client-Server Architecture. Docker daemon executes commands issued by the client by translating them into actionable operations within the Docker environment.

Screenshot-2024-02-08-031526

Image showing Workings of Docker daemon

Docker Daemon Functions

  • Container Management: This involves overseeing the creation, execution, and termination of containers. This actions are performed based on commands received from the Docker client.
  • Networking and Storage: Docker daemon enables seamless integration with resources with the underlying Operating System. Docker Daemon provides containers with access to network ports, storage volumes, and other essential components.
  • Push & Pull images from registry: When a requested image or container isn’t already available locally, Docker daemon interacts with Docker Registry to fetch and deploy the requested resources.
  • Host Operating System: Docker daemon utilizes host operating system resources to manage containers. It communicates with the kernel of the host operating system to execute container operations.
  • Scalability and Flexibility: Docker daemons architecture allows seamless integration with third-party tools and extensions. This enables further customization of container environments.

Understanding Docker Architecture:

1. Client Server Architecture:

Under the hood, docker employs a client-server architecture. Here docker daemon acts as the server component. The Docker client could be the docker cli or the docker desktop application. The interaction between docker client and daemon happens via REST API calls. The docker client acts as a frontend through which user intracts and the docker daemon actually executes all the required commands.

2. Relation between Docker daemon and Docker Client:

When the user intreacts with docker client, eithre through the docker cli or through graphical desktop application, docker client sends the requried commands to the docker daemon. Upon recieving the required instruction the docker daemon actually executes them. The result of this operation (along with potential errors) is then displayed back to the user via docker client.

In a nutshell, Docker client acts as simple frontend while Docker daemon actually manages the resources. The interactions between docker daemon and the docker client ar done through a REST API which acts as a bridge between the client and the server.

3. Relation between Docker daemon and Docker Registery:

Docker Registry is a remote service that stores Docker images and other related information. The registry acts as a central hub through which docker images can be accessed by users. Users can also upload their own images to the registry. DockerHub is one of popular public registry, they can also be privately managed.

When the an image is requested, the docker daemon checks if it exists locally, if it does then starts a contianer using that particular image. If the requested image doesn’t exist locally then the daemon makes a request to the registry to get the required image.

In a nutshell, the Docker daemon manages local resources including containers and images, while the Docker Registry acts as a repository for storing and distributing.

4. Relation between Docker daemon and Docker Engine:

Docker Engine is composed of both containerd and runc, which power Docker’s interal containerization capabilities. Containerd is a high-level container runtime that interacts with Docker daemon to handle container management tasks. On the other hand, As the container runtime interface (CRI), Runc ensures consistent container execution managing the execution of the tasks.

Docker daemon under the Hood

Starting the Docker Daemon

On MacOS and Windows Operating systems, starting Docker Desktop will automatically launch the docker daemon. When you launch the docker desktop application you can see the following screen:

Docker Desktop on Windows

On Linux operating system, the docker deamon could be started using the following command:

$ sudo systemctl start docker

Note: Running this command requirs root privilages.

Stopping the Docker Daemon

On MacOS and Windows Operating Systems, similar to how Docker Desktop is used for starting, it can also be used to manually pause or quit it. Click on the respective icons on status bar (bottom left position) to confirm the action.

Docker Desktop Pause and Quit Options

On Linux, if the process in running in the terminal you can use Cntrl+C to stop it or can alternatively use the following command:

$ sudo systemctl stop docker

Configure the Docker daemon

There are two main ways to configure the Docker daemon:

  1. Use a JSON configuration file.
  2. Using flags when starting dockerd.

Docker daemon directory

The Docker daemon stores data in a single folder. This folder/directory contains everything related to Docker. This directory will include all of containers, images, volumes, service definition, and secrets.

It can be accessed via

  • Linux/macOS : /var/lib/docker
  • Windows: C:\ProgramData\docker on Windows.

Effective debugging

Debugging can be enabled to look runtime activity, helping with troubleshooting. This can be achieved by setting the debug key to true.

  • Linux: Edit daemon.json file located in /etc/docker/.
  • Windows: Go to Preferences / Daemon / Advanced.

Docker Daemon – FAQ’s

On what operating systems Docker daemon run?

While primarily running on Linux, Docker daemon has adaptations for macOS and Windows.

What are the ways to configure Docker daemon?

Docker Daemon can be configured via JSON configuration. This file defines behavior and settings.

What is the role of Docker daemon in container networking and storage?

Docker Daemon facilitates container access to network ports, storage volumes. This allows for seamless integration with the underlying operating system’s resources

Can Docker daemon be scaled for large-scale deployments?

Yes, Docker daemon can cater to diverse deployment needs. This is possible as docker architecture ensures scalability, flexibility, and integration with third-party tools and extensions to cater to diverse deployment needs.

What security considerations should be taken into account when configuring Docker daemon?

When configuring Docker daemon, consider security measures such as enabling TLS, configuring access control, and regularly updating Docker and its dependencies to mitigate potential security risks.

Can Docker daemon manage container networks across multiple Docker hosts?

Yes, Docker daemon can create and manage overlay networks spanning multiple Docker hosts.

How does Docker daemon handle container resource allocation and isolation?

Docker daemon utilizes Linux features like cgroups and namespaces in the Linux kernel. This allocates and isolate resources such as CPU, memory, and filesystems for each container.

Is Docker Daemon responsible for container security?

While Docker Daemon provides mechanisms for isolating containers. We need to ensure that container security is a shared responsibility between Docker Daemon, container images, and host security configurations.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads