Understanding How the Docker Daemon and Docker CLI Work Together
Docker is not a monolithic piece of software. It is composed of a few different tools and this article will cover the daemon and the CLI.
Docker as a whole is composed of many different tools, but when most people talk about installing and using Docker it’s in reference to the Docker daemon and Docker CLI.
Visualizing Docker’s Architecture
Here’s a peek at how Docker works under the hood:
And now let’s define those layers from the bottom up:
The Docker daemon is a service that runs on your host operating system. It currently only runs on Linux because it depends on a number of Linux kernel features, but there are a few ways to run Docker on MacOS and Windows too.
The Docker daemon itself exposes a REST API. From here, a number of different tools can talk to the daemon through this API.
The most widespread tool is the Docker CLI. It is a command line tool that lets you talk to the Docker daemon. When you install Docker, you get both the Docker daemon and the Docker CLI tools together.
It Is a Client <-> Server Architecture
You could describe Docker as a client <-> server application. The daemon is the server, and the CLI is 1 of many clients. There’s also a number of third party clients.
You’ll find one for most popular programming languages, and you can even make your own if you want. After all, you’re just interfacing with a well defined REST API.
You can use the client to manage many different components of the daemon such as images, containers, networks and data volumes.
We cover the official CLI in great detail in the Dive Into Docker course.
How the Client Talks to the Docker Host
Now let’s visualize how some of the pieces come together:
And this time we’ll discuss the above picture from left to right:
First we have the client on the left, this is where we’re running various Docker commands. The client could be installed on your laptop running Windows, MacOS or a server running Linux, it doesn’t matter.
Next up, we have the Docker host. This is typically referred to as the server running the Docker daemon. That makes sense right? It’s the host that happens to be running the Docker daemon.
It’s very simple to configure the Docker client to connect to a remote Docker host. This is one way you’re able to run Docker on MacOS and Windows.
In that case, the Docker daemon ends up running in a virtual machine that uses Linux, and the Docker client is configured to connect to that remote Docker host.
The key take away here is, the client and daemon does not need to be on the same box.
Lastly, we have the registry which is also part of the Docker ecosystem but for now you can ignore it. Discussing what that does goes beyond the scope of this article, but it would have looked weird if I chopped it out because then the arrows would be coming from no where.
Just understand that it’s not something that’s installed by default with Docker, but instead, a place to find and download Docker images.
So that’s how Docker works at a glance.