What Is the Docker Client?

What Is the Docker Client?

A complete, step-by-step guide to the program you type into every day when you use Docker: what it really is, what it does behind the scenes, how it finds the engine it talks to, and how to use it safely and confidently.

You open a terminal, type “docker run hello-world,” and press Enter. A moment later, a friendly message appears on your screen. It feels as if the program you just typed into did all the work: it downloaded something, started something, and printed something. But here is the surprise that surprises almost every beginner. The program you typed into does almost none of that work. It is only a messenger.

The real work is done by a different program, running quietly in the background, that you never see. The program you type into is called the Docker client. Its job is to take what you type, turn it into a clear request, deliver that request to the background program, and show you the answer. This article explains the Docker client from the very beginning: what it is, why it exists, how it talks to the engine, how to connect it to different machines, how to keep it secure, and how to avoid the mistakes that trip up nearly everyone once.

WWhat Is the Docker Client?

Start here. By the end of this chapter you will know what the Docker client is, what it is not, and where it came from.

The Docker client is the command-line program named docker. When you type a command that begins with the word “docker,” you are using the Docker client. It is the main way that people give instructions to Docker: start a container, list running containers, build an image, stop something, look at logs, and so on.

To follow the rest of this article, you only need two simple ideas. A container is a small, isolated box in which a program runs, together with everything the program needs, so that it behaves the same on every computer. An image is the recipe or blueprint from which containers are made. If you have never used either, do not worry: each of them is explained again, with pictures, in Chapter 3.

The client is not the engine

The most important sentence in this article is this one: the Docker client is not the thing that runs containers. Containers are created and managed by a separate background program called the Docker daemon, whose program name is dockerd. The word “daemon” is an old computing term for a program that runs quietly in the background, waiting for work. The client and the daemon are two different programs. They can run on the same computer, or on two computers far apart. They talk to each other using a defined set of messages called the Docker Engine API.

Everyday analogy

Think of a television and its remote control. You press buttons on the remote, but the remote does not show the picture. It sends a small signal to the television, and the television does the real work. The Docker client is the remote control. The Docker daemon is the television. You can change channels, adjust the volume and turn it off, all from the remote, but the picture comes from somewhere else. And just as a remote can be pointed at a different television, the Docker client can be pointed at a different daemon, on a different machine.

2 programs
the client that you type into, and the daemon that does the work
1 language
the Docker Engine API, which they use to talk to each other
Any machine
the client can steer a daemon on your laptop or on a faraway server

A short history

Docker was introduced to the public in 2013, and from the beginning it was built as a client and server system: a small command-line tool talking to a background service. That design was a deliberate choice, and it has proven very durable. Over the years, the client and the engine were separated more clearly. The client’s code lives in its own project, it can be installed on its own, and today it is often packaged separately from the daemon. Around 2017 the open-source project behind the engine was renamed Moby, while the products kept the Docker name. Later, the client gained a plugin system, which is how tools such as the modern image builder and the Compose tool for multi-container applications became part of the same “docker” command. Desktop products for Mac and Windows arrived that hide the daemon inside a lightweight virtual machine, while the client stays on your own computer. The client you use today is a mature, well-tested messenger with a long list of abilities.

Where you meet it

You meet the Docker client on developers’ laptops, on servers, in build machines that produce software, in classrooms, and inside countless scripts and automation systems. Whenever a person or a program types “docker” followed by a word, the client is at work.

i
Word check

Whenever this article says “the client,” it means the program named docker that you type into. Whenever it says “the daemon” or “the engine,” it means the background program that really creates and runs containers. Keeping these two words separate makes everything else easy.

TThe Problem: Why a Separate Client Exists

If the daemon does the real work, why does a client exist at all? To see the answer, imagine life without it.

Running containers is complicated underneath

Behind every container are several deep features of the operating system. Some of them keep containers isolated from each other, so that one cannot see the files or processes of another. Some limit how much memory and processor time a container may use. Others build private networks and virtual file systems. Setting all of that up by hand, for every container, would take a great deal of specialist knowledge and a lot of careful typing. The daemon hides all of that behind simple ideas such as “start this container.”

Talking to the daemon directly is awkward

The daemon listens for requests written in the format of the Docker Engine API, which uses the same style as web requests. You could, in principle, send those requests yourself by hand, but each one would be long, full of details, and easy to get wrong. The client turns a short, friendly phrase such as “docker ps” into the correct request, sends it, waits for the reply, and shows the result in a form that a person can read. It is a translator between human language and machine language.

Everyday analogy

Imagine ordering food in a restaurant where you had to walk into the kitchen and shout instructions to each cook in their own technical language. That would be slow and chaotic. Instead, you tell a waiter what you want, the waiter writes a proper order slip, takes it to the kitchen, and returns with your meal. The Docker client is the waiter: friendly on your side, precise on the kitchen’s side.

Separation gives freedom

Because the client and the daemon are separate, several useful things become possible. The daemon can run on a powerful server while you type on a light laptop. One person can control many machines by pointing the client at each in turn. Other programs, such as build systems, dashboards and scripts, can talk to the same daemon without going through a human-friendly command line at all. And the client can be improved, with new commands and plugins, without changing the daemon.

Example: the laptop and the powerful server

A developer at a company such as Spotify may need to build a large program that takes a long time on a laptop. Instead of waiting, the developer points the Docker client at a powerful shared build machine. The commands look identical, but the heavy work happens on the big machine. The developer’s laptop stays cool and quiet.

Example: the tester with many environments

A tester needs to check an application on a staging machine and, later, on a copy of production. Rather than logging in separately to each machine, she uses one client and switches the machine it points to with a single command. The commands she uses are the same, and only the destination changes.

The client is the part of Docker that you can see. The daemon is the part that does the work.
QuestionWithout a clientWith the Docker client
How do I ask for something?Write long, exact web requests by handType a short command such as “docker ps”
How do I read the answer?Decode raw dataSee a readable table or message
Can I control a faraway machine?Only with careful custom setupYes, by changing where the client points
Can I automate tasks?Yes, but with much effortYes, by placing commands in scripts

In short, the client gives Docker a friendly face. The rest of this article shows how that face works and how to use it well.

CCore Concepts: The Vocabulary You Need

A dozen words unlock the whole subject. Each one is explained with what it is, why it exists, where you meet it, and a picture from everyday life.

Container

A container is an isolated box in which one program runs, together with the files and tools that it needs. From inside, the program feels as if it has a whole computer to itself. From outside, it is just another process on the machine. Containers start in seconds and can be created and thrown away freely. Think of a lunchbox: everything the meal needs is packed inside, and it can be carried anywhere.

Image

An image is a saved, read-only package from which containers are made. It holds the program, its libraries and its settings. You can create many containers from one image, just as you can bake many cakes from one recipe. Images are made of layers stacked on top of one another, which lets Docker share common parts and save space.

Registry

A registry is a place that stores and shares images, like a library of recipes. The best-known public registry is Docker Hub, and many companies run private registries of their own. When you ask for an image that your machine does not have, it is downloaded, or “pulled,” from a registry.

The daemon

The daemon, called dockerd, is the background program that owns your containers, images, networks and storage. It receives requests, carries them out, and reports back. It is the kitchen of the restaurant.

The Docker Engine API

The Docker Engine API is the agreed set of messages that clients use to talk to the daemon. It is versioned, which means that it changes in careful steps and clients and daemons can agree on which version to use. The Docker client is only one of many programs that speak this language. Others include software libraries for programming languages, graphical tools and automation systems. The API is the shared menu that every waiter and every kitchen understand.

The socket

A socket is a special doorway through which two programs on the same computer can talk. On Linux and Mac systems, the daemon by default listens on a socket file, and the client sends its requests through that file. On Windows the same idea uses a named pipe. A socket is like an internal telephone line between two rooms of a building.

The context

A context is a saved description of which daemon the client should talk to, together with any needed security details. You can keep several contexts, such as “laptop,” “staging” and “production,” and switch between them. A context is a speed-dial button on your remote control.

The configuration file

The client keeps its settings in a small file inside your home folder, in a directory named .docker. It records things such as saved logins to registries, the currently chosen context and preferences. Like the settings menu of any program, it saves you from repeating yourself.

Plugins

A plugin is an extra program that adds new commands to the client. The modern image builder, the Compose tool for running groups of containers, and a tool for examining images for known weaknesses are examples. They appear as ordinary subcommands, so from your point of view they simply extend the vocabulary of the remote control.

Command, subcommand and flag

A Docker command has a simple shape. It starts with “docker,” followed by a subcommand that names what you want, such as “run” or “ps,” and often by flags, which are small options that start with a dash and adjust the behavior. Newer commands are grouped by subject: for example, “docker container ls” lists containers, and “docker image ls” lists images. Learning this shape lets you guess many commands you have never seen.

You type

Client

The docker program, which turns your commands into requests and shows the answers.

Does the work

Daemon

The background program that creates and manages containers, images, networks and volumes.

Shared language

Engine API

The agreed messages that clients and the daemon use to talk.

Phone line

Socket

The local doorway through which the client reaches a daemon on the same computer.

Speed dial

Context

A saved target, so you can switch between daemons with one command.

Blueprint

Image

A read-only package from which containers are created.

Running box

Container

An isolated place where a program runs with everything it needs.

Library

Registry

A store of images that can be pulled and pushed.

i
Remember

Client, daemon, API, socket, context. If you keep only five words in your head, keep these. The client speaks the API through a socket to a daemon, and a context remembers which daemon.

AArchitecture and Components

Now let us zoom out and look at the whole machine: which parts exist, where each one lives, and how the client fits among them.

Docker is not one program but a small team of programs. The client is the one on the surface. Behind it are several others, each with a clear job. The diagram below shows the whole chain, from your keyboard down to a running container.

flowchart LR
    USER["You in a terminal"] --> CLI["Docker client - the docker program"]
    CLI -->|"Engine API requests"| SOCK["Local socket or network address"]
    SOCK --> D["Docker daemon - dockerd"]
    D --> CT["containerd - manages container lifecycle"]
    CT --> RC["runc - starts the container process"]
    RC --> C["Running container"]
    D |"pull and push images"| REG["Registry such as Docker Hub"]
    D --> ST["Images, volumes and networks on disk"]
Figure 1. From the terminal to a running container. The client is only the first link in the chain.

Walking through the diagram

On the far left is you, typing in a terminal. The Docker client reads your command and turns it into a request in the language of the Engine API. It sends the request to an endpoint: either a local socket file, when the daemon is on the same computer, or a network address, when it is on another one. The daemon receives the request. It keeps records of all the images, containers, networks and storage volumes, and it decides what needs to happen. To actually start and supervise a container, the daemon relies on a helper called containerd, which manages the life of containers, and containerd relies on a smaller helper called runc, which does the final step of creating the isolated process. The daemon also talks to registries when images have to be downloaded or uploaded.

Everyday analogy

Picture a restaurant. You, the customer, give your order to a waiter (the client). The waiter writes a proper order slip in the kitchen’s language (the API) and passes it through the serving hatch (the socket). The head chef (the daemon) decides what needs to be done, phones the wholesale supplier if an ingredient is missing (the registry), and hands the job to a section chef (containerd), who instructs the person at the stove (runc) to cook the dish. You never enter the kitchen, and the kitchen never needs to meet you.

Where each part lives

ComponentWhat it doesWhere it lives
Docker clientTakes your commands, builds requests, shows resultsYour own computer, or any machine where you type
Engine APIThe agreed messages between client and daemonSpoken over a socket or a network connection
Docker daemonOwns images, containers, networks and volumes, and carries out requestsThe machine that actually runs the containers
containerdManages the life of containers and their images on diskThe same machine as the daemon
runcCreates the isolated process for a containerThe same machine as the daemon
RegistryStores and serves imagesThe internet or your company network
Configuration and contextsRemember logins, targets and preferencesA folder in your home directory
PluginsAdd new commands to the clientFiles next to the client, or in your home directory

One machine or two?

On a Linux computer with Docker installed, the client and the daemon live side by side, and the client speaks to the daemon through a local socket file. On a Mac or a Windows computer, the situation is different, because the containers that Docker runs are built on features of Linux. Desktop products therefore run a small, hidden Linux virtual machine, and the daemon lives inside it. The client stays on your Mac or Windows system and reaches the daemon through a doorway the product provides. From the outside, it looks as if everything is on one machine, but underneath there are still two programs and a bridge between them. That is why a folder on your laptop is not automatically visible inside a container: the daemon runs in another place, and sharing has to be set up.

The client on its own

Because the client is separate, it can be installed without the daemon. Many operating systems offer a package that contains only the client. This is what you want on a machine that will only steer remote daemons, such as a build agent or an administrator’s workstation. The client alone cannot run a single container, but it can command any daemon it is allowed to reach.

!
Tip

When something does not work, first ask which part failed: the client (a typing or configuration problem), the connection (the client cannot reach the daemon), or the daemon (it received the request but could not carry it out). The error message usually says which one, and Chapter 7 shows how to read it.

IInternal Working: What Happens When You Press Enter

This is the engine room. You do not need to be an expert, because every step comes with a picture.

sequenceDiagram
    participant U as You
    participant C as Docker client
    participant D as Docker daemon
    participant R as Registry
    U->>C: docker run hello-world
    C->>C: Read settings and choose the target daemon
    C->>D: Ask which API version you support
    D-->>C: Supported version
    C->>D: Create a container from the image
    D->>R: Pull the image if it is missing
    R-->>D: Image layers
    D-->>C: Container created
    C->>D: Start the container and attach to its output
    D-->>C: Stream the output
    C-->>U: Print the output and exit with the container's exit code
Figure 2. The conversation behind a single “docker run” command.

Step one: read the settings

Before doing anything, the client works out where to send its request. It looks at the command line, at a few environment variables, and at the configuration file to decide which daemon is the target. If you have chosen a context, that context supplies the address. If not, the client falls back to the default local socket. It also reads which registry logins you have saved.

Step two: agree on a language version

The client and the daemon may have been released at different times, so they may know different versions of the Engine API. The client therefore starts with a tiny greeting, asking the daemon which version it supports, and then speaks the newest version that both understand. This is called version negotiation. It is like two travelers who discover that they speak slightly different dialects and agree to use the one they both know. If the daemon is far too old or far too new, the client explains the mismatch, and you can also pin a version by hand.

Step three: turn the command into requests

The command “docker run” is really a short way of saying several things: make sure the image exists, create a container from it with the options you gave, start it, and connect to its output. The client sends these as separate requests. First it asks the daemon to create the container, passing along every option: the name, the ports, the folders to share, the settings for memory and so on. The daemon answers with the identifier of the new container.

Step four: the daemon does the work

If the image is not yet on the machine, the daemon downloads it from the registry, layer by layer, and the client shows a progress display of what the daemon reports. Notice who does what: the daemon talks to the registry, not the client. The client’s part is to carry your saved login details along with the request so that the daemon can identify itself to a private registry. Once the container exists, the client asks the daemon to start it. The daemon hands the job to containerd and runc, which create the isolated process.

Step five: streaming the output

To show you what the program prints, the client keeps the connection open and receives a continuous stream of output. For interactive commands, where you type into a running program, the connection is turned into a two-way channel, so that your keystrokes travel to the container and its answers travel back, just like a telephone call that stays open while both people talk. Two flags control this: one keeps the input open and another gives the program a terminal to talk to, and together they are what make an interactive shell inside a container feel like a normal one.

Step six: finish and report

When the program inside the container ends, the daemon tells the client. The client then prints anything left over and ends with the same exit code that the container’s program produced. An exit code is a small number that says how things went: zero means success, and other numbers mean various failures. Scripts rely on this. The client also uses special codes for its own problems: one for an error from the daemon itself, one for a command that could not be run, and one for a command that was not found.

1

Parse

The client reads your words and options and checks that they make sense.

2

Choose the target

It decides which daemon to talk to from the command line, environment and context.

3

Negotiate

It agrees on an API version with the daemon.

4

Send requests

It sends one or more requests, carrying registry logins when needed.

5

Stream

It shows progress and output as the daemon reports them, and forwards your typing.

6

Exit

It ends with an exit code that scripts and people can read.

Some commands never leave your computer

Not every docker command needs a daemon. Asking for help, showing the client’s own version, listing or switching contexts, and logging in or out only touch local files. They work even when no daemon is reachable. This explains a common beginner puzzle: the command to show versions prints the client’s information but then complains about the server. The client is fine; it just could not reach a daemon.

The build context

Building an image is a special case. The instructions for a build are kept in a file, and they may refer to other files, such as your program’s source code. The client gathers those files into a package called the build context and sends it to the builder. A separate ignore file lets you leave out things that do not belong, such as large folders of temporary files. Sending a huge context is one of the most common reasons for slow builds, and Chapter 14 returns to it.

!
Watch out: different clients, different servers

Because the client and daemon are separate, their versions can differ. A very new client talking to a very old daemon may offer commands that the daemon does not understand, and the reverse can also happen. Keep them reasonably close in age, and use the version command, which reports both, when you suspect a mismatch.

DData Flow and Lifecycle

Containers are born, live, rest and die, and each step is triggered by a client command. Knowing this lifecycle makes every command easier to understand.

stateDiagram-v2
    [*] --> Created : docker create
    Created --> Running : docker start
    Running --> Paused : docker pause
    Paused --> Running : docker unpause
    Running --> Exited : program ends or docker stop
    Exited --> Running : docker start
    Exited --> Removed : docker rm
    Created --> Removed : docker rm
    Removed --> [*]
Figure 3. The life of a container, and the client commands that move it from one state to another.

The states, one by one

A container begins as created: it exists as a set of settings and a file system, but no program is running yet. When you start it, it becomes running. A running container can be paused, which freezes its processes without ending them, and later unpaused. When its program ends, or when you stop it, the container becomes exited. It still exists, with its files and logs intact, and can be started again. Only when you remove it does it truly disappear. Many people are surprised that stopped containers stay on the disk until they are removed, which is why old ones pile up and need cleaning.

The shortcut: run

The command you will use most, “docker run,” is a combination: it creates a container and starts it, downloading the image first if needed. If you add the option to run in the background, the client returns your prompt immediately and the container keeps working. If you add the option that removes the container when it ends, no leftover exited container remains.

Everyday analogy

Think of a lamp. “Created” is a lamp taken out of its box and placed on the table. “Running” is the lamp switched on. “Paused” is holding the switch halfway, and “exited” is the lamp switched off but still on the table. “Removed” is putting the lamp back in the shop. The client’s commands are the hands that unpack, switch, hold and remove.

Three flows of data

Data travels between the client, the daemon and the registry in three main ways. First, commands and answers: small requests go to the daemon, and status information and output come back. Second, the build context: when you build, the client uploads the files needed for the build. Third, credentials: when the daemon must pull from or push to a private registry, the client supplies the login details, drawn from your saved settings, and the daemon uses them to speak to the registry. Images themselves flow between the daemon and the registry directly. They do not pass through the client.

What you typeWhat the client sendsWhat travels back
docker psA request for the list of containersThe list, which the client formats as a table
docker runRequests to create and start a containerProgress, the program’s output and its exit code
docker buildThe build context and the build settingsBuild progress and the new image’s identifier
docker pullThe image name and the registry loginProgress reported by the daemon
docker logsThe container name and optionsA stream of the container’s printed messages
docker execA request to start a command inside a containerA two-way stream for the command’s input and output
1

Pull

The daemon downloads the image from a registry if it is not already present.

2

Create

The daemon prepares a container with the settings that the client passed.

3

Start

The program inside the container begins to run.

4

Observe

You look at status, logs, and resource use with client commands.

5

Stop

The daemon asks the program to finish politely, and forces it if it does not.

6

Remove

The container’s leftovers are deleted, so nothing accumulates.

!
Watch out: data disappears with the container

Files written inside a container vanish when the container is removed. Anything you need to keep must be stored in a volume, a separate storage area managed by Docker, or in a folder shared from the host. Beginners often lose work by forgetting this.

YYour First Session: A Guided Tour

Before going deeper, here is a short, safe walk through the client’s most common commands. Follow it once, and the rest of the article will feel familiar.

Before you begin

You need Docker installed on your computer. On Mac and Windows, the usual choice is a desktop application that includes both the client and a hidden daemon. On Linux, you can install the engine packages, and, if you wish, a separate client package. After installation, open a terminal. Every command below is typed there.

1

Ask for the versions

Type “docker version.” You will see a Client section and a Server section. If the Server section shows a connection error, the client is fine but no daemon is reachable, so start Docker Desktop or the service.

2

Look at the big picture

Type “docker info.” It prints facts about the daemon: how many containers and images it holds, where it stores data, and which features are on.

3

Run the tiny test

Type “docker run hello-world.” The daemon pulls a very small image, runs it, and the container prints a greeting and exits. This proves the whole chain works.

4

Start something useful

Run a web server container in the background, with a port on your computer connected to the port inside. The client returns your prompt right away, printing the container’s identifier.

5

List what is running

Type “docker ps.” You will see a table with the container’s name, image, status and ports. Add the option to show all containers, and exited ones appear too.

6

Look at it in a browser

Open the address of your own computer on the port you chose, and you will see the web server’s welcome page.

7

Read its messages

Type “docker logs” followed by the container’s name. You will see the requests your browser just made. Adding the follow option keeps the stream open.

8

Step inside

Type “docker exec” with the interactive options and a shell program. You are now typing inside the container. Leave with the exit command.

9

Stop and remove

Type “docker stop” and then “docker rm” with the container’s name. The web server goes away.

10

Tidy the images

Type “docker images” to see the images you downloaded, and remove the ones you no longer need with “docker rmi.”

Reading the common error

The message beginners meet most often says that the client cannot connect to the daemon. It appears when the daemon is not running, when the client is pointed at the wrong address, or when you do not have permission to use the socket. The three fixes match the three causes: start the daemon, check which context or address the client uses, and, on Linux, make sure your user is allowed to use Docker, keeping in mind the security warning in Chapter 12.

Everyday analogy

This first session is like learning to drive in an empty car park. You start the engine, move forward, turn, stop and park, all without the pressure of traffic. Once each control feels familiar, taking the same car onto a real road is much less frightening.

!
Tip

Give your containers names with the name option and use the option that removes a container when it ends, for practice runs. Named containers are easy to refer to, and self-removing ones do not leave clutter behind.

TTalking to Different Daemons: Sockets, Networks, SSH and Contexts

One of the client’s best tricks is that it can steer any daemon it can reach. This chapter shows how it finds the daemon, and the different ways it can connect.

flowchart TD
    S["A docker command starts"] --> A{"Host or context option on the command line?"}
    A -->|"Yes"| H1["Use that target"]
    A -->|"No"| B{"Environment variable for host or context set?"}
    B -->|"Yes"| H2["Use the target from the variable"]
    B -->|"No"| C{"A current context saved in the settings?"}
    C -->|"Yes"| H3["Use the address stored in that context"]
    C -->|"No"| H4["Use the default local socket"]
Figure 4. How the client decides which daemon to talk to. Command-line choices beat environment variables, which beat saved settings.

How the client chooses

The client follows a simple order of priority. Something you type on the command line beats an environment variable, and an environment variable beats what is saved in the settings. If nothing at all is specified, the client uses the default local socket. The exact details can differ a little between versions, so when in doubt, ask the client which target it is using, as Chapter 13 explains.

Five ways to connect

MethodWhat it isGood forMain caution
Local socketA special file on the same computer, used on Linux and MacEveryday work when the daemon is on your machineWhoever can use the socket has near-total control of the machine
Named pipeThe Windows version of a local doorwayEveryday work on WindowsThe same power as the socket
Plain network addressA daemon listening on a network port, by convention 2375Almost nothing outside of isolated testsNo encryption and no login, so anyone who can reach it controls the machine
Network address with encryptionThe same, but protected with certificates on both sides, by convention port 2376Controlled remote access in managed setupsCertificates must be created, protected and renewed
SSHThe client uses a secure shell connection to reach the remote machineSteering a remote daemon with the tools and keys you already useThe remote machine needs Docker installed and your key must be protected
Everyday analogy

Imagine several ways to give an order to a factory manager. Walking down the hallway and speaking to them (the local socket) is easy and needs no ID, because you are already inside the building. Shouting through an open window on the street (a plain network address) is dangerous, because anyone passing by can shout an order too. Using a secure phone line where both sides must show an ID card (encrypted network address) is safe but takes setup. Sending a trusted courier with your signed note (SSH) is safe and uses a service you already have.

Why the local socket is powerful

The local doorway is not protected by a password. It is protected by file permissions: only the administrator and members of a special group can use it. Anything that can talk to it can ask the daemon to start containers that reach into the machine’s files. For that reason, access to the Docker socket is treated as the same as administrator access. Chapter 12 returns to this point, because it is the most important safety fact about the client.

Contexts: speed dial for daemons

Typing long addresses every time would be tiring and risky. A context stores a name, an address and the security details, so that you can switch with a short command. You can create a context, list your contexts, see which one is active, switch to another, and remove one you no longer need. Desktop products usually add their own context automatically. With contexts, moving from your laptop’s daemon to a staging server and back is a one-word change, and every command you type afterward goes to the new target.

Using a context for one command

You can also choose a context for a single command without switching, by naming it in that command. This is safer for important actions, because your normal setting stays on the harmless local daemon, and only the one command you consciously aimed goes elsewhere.

Example: two environments, one client

An operations engineer at a company such as Shopify keeps three contexts: “local,” “staging” and “production.” Her shell prompt shows the name of the active context in colour, so she always knows where her next command will go. Before any risky action she looks at the prompt, and for anything that changes production she uses the one-command form instead of switching.

!
Watch out: the wrong daemon

The most expensive Docker mistakes are not typing errors. They are commands that were correct, but sent to the wrong machine. Always check which context is active before running anything destructive, and make that information visible in your prompt.

!
Tip

For remote machines, prefer SSH or encrypted network access over anything else. SSH reuses keys and rules you already manage, and it does not require you to open a special port on the remote machine to the world.

TThe Command Map: What the Client Can Do

The client has many commands, but they follow a pattern. Once you see the pattern, the whole map fits on one page.

The shape of a command

Modern Docker commands are grouped by subject, like drawers in a cabinet. The first word after “docker” names the drawer, such as container, image, network or volume. The second word is the action, such as ls to list, rm to remove, or inspect to see details. So “docker container ls” lists containers and “docker image rm” removes an image. Older short forms, such as “docker ps” for listing containers and “docker images” for listing images, still work and are very popular, because they are quicker to type.

SubjectWhat it is aboutCommon actions
containerRunning and stopped containersRun, start, stop, restart, list, remove, inspect, logs, exec, copy files
imageThe blueprintsPull, push, list, remove, build, tag, inspect, history
networkVirtual networks that connect containersCreate, list, connect, disconnect, inspect, remove
volumeStorage that survives a containerCreate, list, inspect, remove
systemThe daemon as a wholeShow disk use, show events, clean up unused data, show information
contextSaved targets for the clientCreate, list, switch, inspect, remove
login and logoutAccess to registriesSave or remove registry credentials
builder and buildxThe modern image builderBuild images, manage builders, and build for several computer types
composeGroups of containers described in one fileStart, stop and inspect a whole application

Flags: small options with big effects

Flags adjust a command. For running containers, the most common ones are: run in the background, give the container a name, connect a port of your computer to a port of the container, share a folder, set an environment variable, limit memory, and remove the container when it ends. You do not need to memorize them. The help option, added to any command, prints a clear summary of everything it accepts.

Filtering and formatting

When you have hundreds of containers, a plain list is unwieldy. Many commands accept a filter option, which narrows the list to items that match, for example only containers that have exited. They also accept a format option, which lets you choose exactly which columns to print, or print the raw data in a structured form that other programs can read. This is what makes the client so useful in scripts: you can ask for precisely the piece of information you need, with no extra text to strip away.

Inspecting things

The inspect action prints a complete technical description of any object, from a container to a network, as structured data. It is your microscope: settings, addresses, mounted folders, health status and much more are all visible there. Combined with the format option, you can extract one value, such as a container’s internal address.

Everyday analogy

The command map is like the menu of a well-organized restaurant, divided into starters, mains and desserts. Once you know the sections, you can find any dish quickly. Filters are like asking “only the vegetarian dishes,” and the format option is like asking for the price list without the descriptions.

Start

run

Create and start a container, pulling the image first if needed.

Look

ps

List containers. Add the option for all to include stopped ones.

Read

logs

Show what a container has printed, and follow new lines as they appear.

Enter

exec

Run a command inside a running container, such as a shell.

Examine

inspect

Show every detail about a container, image, network or volume.

Measure

stats

Show live use of processor, memory and network for running containers.

Build

build

Create an image from a set of instructions and files.

Clean

system prune

Remove unused data. Powerful, so read what it will remove first.

!
Tip

Turn on command completion for your shell. Pressing the tab key then finishes command names, subject names and even container names, which saves typing and prevents mistakes.

CConfiguration, Credentials and Plugins

The client remembers things about you: which registries you use, which target you chose, and how you like your output. Knowing where this is kept explains many puzzling behaviors, and matters for security.

The configuration file

The client’s settings live in a small file, in a folder called .docker inside your home directory. It records saved registry logins or pointers to a secure store for them, the currently selected context, preferences about output, settings for a network proxy that containers should use, and the list of extra plugin folders. You can choose a different folder for this file with an environment variable, which is very useful in build systems where several jobs must not share logins.

Logging in to a registry

To pull private images or push your own, you log in to a registry with the “docker login” command. The client asks for your user name and a secret, sends them to the registry to check, and saves the result. Where it saves the result matters greatly. If you have set up a credential helper, a small program that stores secrets in the safe storage of your operating system, such as a system keychain, the client hands the secret to it. If you have not, the client writes the credentials into the configuration file, encoded but not encrypted. Encoding is like writing a message in a different alphabet that anyone can read back; it offers no protection.

Everyday analogy

A credential helper is like a bank safe for your passwords, and the plain configuration file is like a sticky note on the fridge. Both work when you are hungry for an image, but only one of them stops a visitor from reading your secret. Always prefer the safe.

Using login safely

Never type a secret directly into the command line, since it will be saved in your shell history and may be visible to other users on the machine. Instead, use the option that reads the secret from standard input, such as from a file or a secret manager, and use tokens with limited rights rather than your main password.

Environment variables

VariableWhat it controls
DOCKER_HOSTThe address of the daemon to talk to
DOCKER_CONTEXTWhich saved context to use for this command or session
DOCKER_CONFIGThe folder that holds the configuration file, so that you can keep separate settings
DOCKER_TLS_VERIFYWhether to require an encrypted and verified connection to a network daemon
DOCKER_CERT_PATHWhere the certificates for an encrypted connection are found
DOCKER_API_VERSIONA pinned Engine API version, instead of automatic negotiation
DOCKER_CONTENT_TRUSTWhether to accept only signed images when pulling

Plugins

Plugins are separate programs that the client finds in special folders and presents as ordinary subcommands. That is how the image builder and the Compose tool become part of the “docker” command. The information command lists the plugins the client has found and their versions. Plugins let Docker add features without making the core client larger, and they allow third parties to add commands of their own. Because a plugin is a program that runs with your rights, you should install plugins only from sources you trust.

Example: separate settings for separate jobs

A shared build server at a large company may run dozens of jobs at once, each with different registry logins. By giving each job its own configuration folder through the environment variable, the jobs cannot see each other’s credentials, and one job logging out does not break another.

!
Watch out: secrets in the settings file

Open your configuration file once and look at what it holds. If you see saved logins that are merely encoded, set up a credential helper and log in again. Also make sure the file is never copied into images, shared in support requests, or committed to a code repository.

AAdvantages, Disadvantages and Trade-offs

The Docker client is a well-loved tool, but it is not the only way to talk to a daemon, and it has limits. Knowing them helps you choose wisely.

Advantages

  • Simple, memorable commands for very complex work.
  • Works the same on Linux, Mac and Windows.
  • Can steer local or remote daemons through contexts.
  • Easy to script, with filters and structured output.
  • Extensible through plugins such as the builder and Compose.
  • Huge community, documentation and examples.
  • Can be installed alone, as a light tool for remote administration.

Disadvantages

  • Text-only, so it can be hard to see the big picture of many containers.
  • Power without a safety net: destructive commands run without much warning.
  • Access to the daemon is close to full control of the machine.
  • Version differences between client and daemon can cause confusing errors.
  • Credentials can end up stored weakly if not configured carefully.
  • Commands are one-off, so repeatable setups need files and scripts.
  • Tied to the Docker Engine API, so other engines need a compatible layer.

Trade-off one: convenience versus safety

The client makes powerful actions easy. That is its great strength and its main danger. A single command can remove every stopped container, or every unused image. The remedy is not to avoid the client but to build habits: read a command before you press Enter, check the active context, and use options that ask for confirmation.

Trade-off two: typing versus describing

Typing commands is quick for exploration, but a system built from typed commands is hard to repeat exactly. As soon as something matters, it should be described in a file, such as a Compose file or a script, and kept in version control. The client is then the tool that carries out the description, and no longer the place where the knowledge lives.

Trade-off three: the client versus other clients

Other programs also speak the Docker Engine API, and other tools offer a similar command line for other engines. Which one suits you depends on what you need.

OptionWhat it isBest for
The Docker clientThe standard command-line programDaily work, scripts, remote administration
Desktop applicationA graphical window on top of the same engineBeginners who want a visual overview
Language librariesCode libraries that speak the Engine API directlyPrograms that manage containers, such as test frameworks and tools
Web dashboardsBrowser-based tools that connect to one or many daemonsTeams who want shared, visual management
Compatible command lines for other enginesTools that copy the docker command style but work with other container enginesEnvironments that avoid a central daemon or use another runtime
Everyday analogy

The client is like a good kitchen knife: sharp, versatile and used every day. A food processor (a graphical tool) is easier for some jobs, and a factory machine (a library used by another program) is better for repeating the same task a million times. A wise cook keeps the knife, and knows when to reach for something else.

Most teams end up using the client for exploration and operations, files and libraries for repeatable automation, and dashboards for shared visibility.

SSecurity: The Most Important Chapter

The Docker client is powerful, and power needs care. This chapter explains the key safety facts, none of which require special skills to follow.

The central fact: access to the daemon is administrator access

The daemon usually runs with the highest rights on the machine. Anyone who can send it requests can ask it to create containers that reach into the machine’s files and settings. For this reason, permission to use the Docker socket is, in practice, the same as administrator permission. On Linux, adding a user to the group that may use the socket is therefore a serious decision, not a convenience. The diagram below shows the logic in simple steps.

flowchart LR
    A["Anyone who can reach the Docker socket or an open network port"] --> B["Asks the daemon to start a container"]
    B --> C["The container is given access to folders of the host machine"]
    C --> D["Files on the host can be read or changed"]
    D --> E["Effective control of the whole machine"]
Figure 5. Why access to the Docker daemon is treated as administrator access.
Everyday analogy

Access to the daemon is like holding the master key of a building. A master key does not look dangerous, and it does not shout. But whoever holds it can open every door, so you give it only to people you trust completely, and you never leave it hanging on a hook by the front entrance.

Rules that follow from it

1

Limit who can use the socket

Treat membership of the Docker group like membership of the administrators group, and review it regularly.

2

Never expose the plain network port

A daemon listening without encryption or a login is open to anyone who can reach it. Use SSH or certificates on both sides instead.

3

Do not hand the socket to containers

Sharing the daemon’s socket with a container gives that container the master key. If a program there is compromised, so is the machine.

4

Consider rootless mode

The daemon can be run by an ordinary user, without administrator rights, which greatly reduces what a mistake or an attack can reach. It has some limits, so test it for your needs.

5

Protect credentials

Use a credential helper, tokens with narrow rights, and secrets read from files or managers, never typed into a command.

6

Trust what you pull

Prefer official or verified images, pin versions, consider signed images and use scanning tools to check for known weaknesses.

Other everyday risks

Secrets placed in environment variables, or in command options, can be seen later by anyone who can inspect the container or read the shell history. Very high-privilege options, such as the one that removes most isolation from a container, should be avoided unless truly needed. Plugins and downloaded client programs run with your rights, so obtain them only from official sources and verify them. Finally, keep the client and the engine up to date, since security fixes are released regularly.

RiskWhy it mattersProtection
Wide access to the socketIt is equal to administrator accessRestrict the group, review members, use rootless mode where possible
Open network port without encryptionAnyone who can reach it controls the machineUse SSH or certificates on both sides, and firewalls
Socket shared with containersA compromised container can take over the machineAvoid it, or use narrow, controlled alternatives
Weakly stored loginsEncoded credentials are easy to readCredential helpers and tokens with limited rights
Secrets on the command lineThey stay in history and process listsRead secrets from standard input or a secret manager
Untrusted images and pluginsThey may contain harmful or vulnerable codeOfficial sources, pinned versions, scanning and signatures
Wrong targetCorrect commands sent to the wrong machineVisible context in the prompt and one-command targeting
!
Watch out: convenient shortcuts

Two habits cause a great deal of trouble: running every command as the administrator just to avoid permission errors, and opening the network port “temporarily” to make a remote tool work. Temporary openings have a way of staying open for years. Solve the permission or access problem properly instead.

MMonitoring, Logging and Metrics

The client is your window into the daemon. Here are the commands that show what is happening, and the signs to watch for.

Which target, which versions?

Two quick checks answer most “why is this strange?” questions. The version command shows the client and the daemon side by side, so you can spot a mismatch or a missing daemon. The context command shows which target is active, so you can spot a wrong destination. Make these your first steps whenever behavior surprises you.

Seeing what containers are doing

The list command shows status at a glance, including health when a container defines a health check, a small test that Docker runs regularly to ask “is the program still working?” The logs command shows what a container has printed. The stats command shows live use of processor, memory and network for each running container, in the style of a task manager. The events command shows a live feed of what the daemon is doing: containers starting, stopping, dying or being created. Together these four give you a complete picture of everyday health.

Seeing what Docker is using

Docker quietly collects data: images, stopped containers, volumes and build leftovers. The system disk-usage command shows how much space each kind takes. Watching it prevents the classic surprise of a full disk. The information command reports counts of containers and images and the location where Docker keeps its data.

Debugging the client

The client has a debug option that makes it print more detail about what it is doing, and a log-level option for finer control. These help when the client and daemon fail to agree on something. The daemon’s own messages live in the system’s log, not in the client, so when the client says “the daemon returned an error,” look there for the reason.

What to watchCommand that shows itHealthy sign
Client and daemon versionsdocker versionBoth present and reasonably close in age
Which daemon is targeteddocker context ls or the context show actionThe one you intended
Container status and healthdocker psRunning, and healthy where a check exists
Restarts and crashesdocker ps, docker eventsNo repeated restarts
Resource usedocker statsMemory and processor within limits
Disk usedocker system dfStable, with reclaimable space managed
Container messagesdocker logsNo repeating errors
Exit codesThe shell’s last resultZero for success in scripts
Everyday analogy

These commands are the dashboard of a car. The version and context checks are the badge that says which car you are in. The list is the fuel and temperature gauges, the logs are the messages on the screen, the events feed is the flashing indicator lights, and the disk report is the trip computer that warns you before you run out of fuel.

!
Tip

In scripts, wait for events rather than checking the list in a tight loop. Polling wastes effort and can overload a busy daemon, while an event feed simply tells you when something changes.

PPerformance, Scalability and Reliability

The client itself is light, but the way you use it can make Docker feel fast or slow. Here are the habits that matter.

The client is thin

Almost all the work happens in the daemon and on the network, not in the client. A command such as listing containers costs the client almost nothing, and any slowness usually comes from the daemon, the disk or the network between the two.

Keep the build context small

The biggest avoidable slowness comes from the build context. If you build in a folder that also holds large data files, downloaded packages or old outputs, the client packs and uploads all of it, every time. Use the ignore file to leave out everything that the build does not need. When the daemon is on another machine, the upload crosses the network, and a small context saves a great deal of time.

Mind the distance

A client steering a remote daemon feels every millisecond of delay. Commands that stream a lot of output, or that make many small requests in a script, become slower. For heavy work, consider running the script closer to the daemon, or use a remote builder for images.

Scale with filters and formats

A machine with thousands of containers produces long lists. Ask for only what you need, with filters and formats, so that less data has to be fetched, shown and processed.

Build systems and registries

Build machines pull the same images again and again. Reusing cached layers, keeping a nearby mirror of popular images, and logging in to registries all reduce delays. Public registries also apply limits to how many anonymous downloads one address may make, so unauthenticated build machines can hit a wall at busy times.

Reliability in scripts

Write scripts so that they can be run twice without harm. Give containers fixed names and remove leftovers first, use options that remove containers when they end, check exit codes, and set sensible timeouts. Use health checks so that a script can wait until a program is really ready, rather than sleeping for a guessed number of seconds.

Speed

Small context

Use the ignore file so that only what the build needs is uploaded.

Speed

Layer caching

Order build steps so that rarely changing parts come first and can be reused.

Speed

Nearby mirror

Keep popular images close to build machines to avoid repeated downloads.

Scale

Filters and formats

Fetch only the data you need when there are many containers.

Trust

Idempotent scripts

Design commands so a second run does no harm.

Trust

Health checks

Wait for real readiness, not for a guessed delay.

!
Watch out: cleaning too much

The command that removes unused data can free a lot of space, but with the option for all images it also removes images that are only unused at this moment. On a busy build machine, that means the next job must download everything again. Clean on a schedule and with care.

DDesign Patterns and Anti-Patterns

Patterns are recipes that experienced teams keep repeating because they work. Anti-patterns are the traps those same teams learned to avoid.

Patterns worth copying

Pattern

One context per environment

Keep named targets for local, staging and production, and show the active one in your prompt.

Pattern

SSH for remote access

Reach remote daemons through SSH, so no extra network port needs to be opened.

Pattern

Describe, do not type

Keep setups in files under version control, and let the client carry them out.

Pattern

Separate settings per job

Give each build job its own configuration folder so credentials never mix.

Pattern

Scripts read structured output

Use formats and filters to extract exact values, instead of cutting up text.

Pattern

Credential helper always

Store registry logins in the operating system’s safe storage.

Traps to avoid

ANTI-PATTERN 01Avoid
What it looks like

Opening the daemon’s plain network port so that a tool or a colleague can connect.

Why it hurts

The port has no encryption and no login, so anyone who can reach it gets control of the machine.

Do this instead

Use SSH, or a network address protected by certificates on both sides.

ANTI-PATTERN 02Avoid
What it looks like

Sharing the daemon’s socket with build containers so that they can run Docker commands.

Why it hurts

Any weakness in that container becomes a weakness of the host. It also makes builds able to affect each other.

Do this instead

Use isolated builders, remote build services or a separate, disposable daemon for each job.

ANTI-PATTERN 03Avoid
What it looks like

Typing passwords or tokens directly into login or run commands.

Why it hurts

The secret is stored in the shell history and may be visible in process lists.

Do this instead

Read secrets from standard input or a secret manager, and use tokens with narrow rights.

ANTI-PATTERN 04Avoid
What it looks like

Running destructive commands without checking which daemon is targeted.

Why it hurts

A correct command sent to production by accident can remove real containers and data.

Do this instead

Show the context in the prompt, and aim risky commands at a target explicitly, one at a time.

ANTI-PATTERN 05Avoid
What it looks like

A system whose only description is a list of commands somebody typed once, kept in a note or in memory.

Why it hurts

It cannot be repeated exactly, cannot be reviewed, and is lost when the person leaves.

Do this instead

Put the description in files under version control and run them through the client.

BBest Practices and Common Mistakes

A short, practical checklist drawn from careful teams, followed by the mistakes that trip up nearly everyone once.

1

Remember the two programs

The client is the remote control and the daemon is the television. Most problems are easier to solve when you ask which of the two is at fault.

2

Check the target first

Look at the active context before any command that changes or deletes something.

3

Keep versions close

Update the client and daemon together and read release notes for changes.

4

Secure the doorway

Limit socket access, avoid open ports, prefer SSH or certificates, and consider rootless mode.

5

Protect your credentials

Use a credential helper and tokens with limited rights, and read secrets from standard input.

6

Name and clean up

Give containers names, use the remove-on-exit option for temporary work, and clean unused data on a schedule.

7

Store data in volumes

Keep anything you need in volumes or shared folders, never only inside a container.

8

Write it down as files

Once something matters, describe it in files under version control instead of retyping commands.

Common mistakes and their cures

MistakeWhat you seeThe cure
Daemon not runningAn error that the client cannot connectStart Docker Desktop or the service, then try again
Permission denied on the socketThe client is refused accessUse an authorized account, and think about the security cost before widening access
Wrong contextContainers missing, or changes on the wrong machineCheck the active context and show it in the prompt
Data lost after removing a containerFiles goneUse volumes or shared folders for anything valuable
Using the latest tag everywhereDifferent results on different daysPin specific versions of images
Piles of stopped containers and old imagesA full diskUse the remove-on-exit option and clean regularly
Huge build contextVery slow buildsUse the ignore file and a tidy project folder
Port already in useThe container cannot startChoose another host port or stop the program using it
Version mismatchOdd errors or missing featuresCompare client and daemon versions and upgrade together
Ignoring exit codes in scriptsFailures go unnoticedCheck results after every important command
!
Tip

Keep a small personal cheat sheet with the ten commands you use most, and the two checks you always make before a risky one: the target and the command itself. A tiny habit prevents most disasters.

RReal-World and Industry Examples

Here is how the Docker client is used in different settings. Named companies below are used as familiar illustrations of the kind of scale and problem involved, not as claims about their internal systems.

The developer’s laptop

A developer at a company like Spotify uses a desktop product that runs the daemon in a hidden virtual machine. Her client talks to it through a local doorway. All day she starts a database, a web server and a message system with a few commands, exactly like the production setup, and throws them away at night.

The build pipeline

A software team that uses a hosted automation service such as GitHub Actions runs a pipeline that starts a clean build machine for each change. The Docker client on that machine builds an image, tests it, logs in to a registry using a short-lived token, and pushes the result. When the job ends, the machine is destroyed, and nothing is left behind.

The remote deployment

A small team runs its application on one server. From a laptop, an engineer uses an SSH-based context to point the client at that server, and updates the application with the same commands she uses locally. No extra network port is opened, and no special tools are installed on the laptop beyond the client.

The classroom

A university teaching software engineering gives every student the same starting environment through a single image. Students run one command and get an identical set of tools, regardless of whether they use Windows, Mac or Linux. Teachers spend their time teaching, not repairing individual laptops.

The regulated bank

A bank such as HSBC lets developers use the client only against tightly controlled, rootless daemons, with registry access through a company mirror and only approved, scanned images. The client is the same program, but the surrounding rules turn its power into something safe to hand out.

A complete walk-through: from laptop to server

To make everything concrete, here is a typical journey of a small application, and how the client is used at each step.

1

Try it locally

The developer runs the application and its database as containers on her own daemon, using short commands and a Compose file.

2

Build an image

She builds an image from the project, with an ignore file to keep the build context small, and tags it with a version.

3

Log in safely

She logs in to the company registry through a credential helper, reading a token from a secret store.

4

Push

She pushes the image. The daemon uploads it, using the login that the client supplied.

5

Switch context

She creates an SSH-based context for the staging server and checks that her prompt shows it.

6

Deploy

She pulls and starts the new version on staging with the same commands she used locally, then reads the logs and checks the health status.

7

Promote

After tests pass, a colleague repeats the steps with the production context, targeting each command explicitly.

8

Clean up

Old containers and unused images are removed on a schedule, and disk use is watched.

Through all eight steps, the client never changed. Only the target changed, and the client’s simple job of carrying your words to a daemon stayed the same.

FFrequently Asked Questions

Short answers to the questions that beginners ask most often.

Q1What is the Docker client in one sentence?
It is the command-line program named docker that turns your commands into requests and sends them to a Docker daemon, which does the real work of running containers.
Q2What is the difference between the Docker client and the Docker daemon?
The client is the program you type into. The daemon is a background program that creates and manages containers, images, networks and volumes. They are separate and talk through the Docker Engine API.
Q3Can the client and the daemon be on different computers?
Yes. The client can reach a remote daemon through SSH or an encrypted network connection, and you can save such targets as contexts and switch between them.
Q4Why does the version command show a Server error?
Because the client works but cannot reach a daemon. Start Docker Desktop or the Docker service, or check that the client is pointed at the correct target.
Q5Does the client download images itself?
No. The daemon downloads and uploads images. The client sends the command and supplies your saved registry login so that the daemon can identify itself.
Q6What is a context?
A saved target for the client: a name, an address and any security details. Contexts let you switch between your laptop, staging and production with a single command.
Q7Is it safe to add my user to the Docker group?
Only if you trust that user with administrator-level power, because access to the daemon is effectively equal to administrator access on that machine. Review the group’s membership regularly.
Q8Where does docker login store my password?
In the operating system’s secure store if you have set up a credential helper. Otherwise it is written to the client’s configuration file in an encoded form that is not encrypted, so set up a helper.
Q9Can I install only the client?
Yes. Many systems offer a client-only package. It is useful for machines that only control remote daemons, and it cannot run containers by itself.
Q10Why did my data disappear when I removed a container?
Files written inside a container are removed with it. Keep important data in a volume or a shared folder so that it survives.
Q11Are there alternatives to the Docker client?
Yes. Graphical desktop applications, web dashboards, code libraries that speak the Engine API, and command-line tools for other container engines that copy the docker style all exist. The right choice depends on your needs.
Q12How do I stop typing long commands again and again?
Put the setup in a file, such as a Compose file, keep it under version control, and let the client run it. Use contexts for targets and shell completion for speed.

SSummary and Key Takeaways

The whole article in one place. If you remember only this box, you still know the essentials.

Key Takeaways

  • What it is: The Docker client is the command-line program named docker. It is a messenger that turns your commands into Docker Engine API requests and shows you the answers, while the Docker daemon does the real work.
  • Two programs, one language: The client and the daemon are separate, so they can live on different machines, and they talk through a socket or a network connection using the Engine API, agreeing on a version first.
  • Everything starts in the client: Commands follow a simple shape of subject and action, with flags, filters and formats, and cover containers, images, networks, volumes, builds and more, extended by plugins such as the builder and Compose.
  • Contexts steer the target: Save named targets for laptop, staging and production, prefer SSH or encrypted connections for remote daemons, and always check which target is active before a risky command.
  • Security is about the doorway: Access to the daemon equals administrator access, so restrict the socket, never expose a plain network port, avoid sharing the socket with containers, consider rootless mode, and protect credentials with helpers and narrow tokens.
  • Watch and tidy: Use the version, list, logs, stats, events and disk-usage commands to see what is happening, keep build contexts small, and clean unused data on a schedule.
  • Describe, do not just type: Once something matters, keep it in files under version control, and let the client carry it out, so that it is repeatable, reviewable and safe.