Using the Docker Client & Server

Niluka Sripali Monnankulama
Many Minds
Published in
5 min readDec 24, 2019

After installing a piece of software called Docker for Windows or Docker for Mac, depending upon your operating system inside this program, there are two very important tools that I am going to be discussed in this blog.

$ docker version

The output gives you detailed information about the installed version of Docker:

The first tool that’s inside this package is something called the Docker client the Docker client also known as the or CLI is a program that you and I are going to interact with quite a bit from our terminal.

We’re going to enter in commands to our terminal issue them to Docker client. It’s going to take our commands and figure out what to do with them.

Docker client itself doesn’t actually do anything with containers or images. Instead, the Docker client is really just a tool or a portal of sorts to help us interact with another piece of software that is included in this Docker for Windows or Mac package called the Docker server.

This is also frequently called the Docker daemon. This program right here is the actual tool or the actual piece of software that is responsible for creating containers images maintaining containers uploading images and doing just about everything you can possibly imagine around the world of docker.

So it’s the docker client that you and I issue commands to. It’s the thing that we interact with and behind the scenes.

This client is interacting with the docker server. You and I never going to really reach directly out to the Docker server.

It’s something that’s just kind of running it behind the scenes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now I want to write out our very first kind of meaningful command with the Docker client or Docker CLI, We’re going to run a very quick command here and then we’re going to go through a very specific flow of actions that occurred when that command got executed.

So here’s the command. in your terminal,

It says unable to find image hello-world locally.

So what then mind let’s go take a look at a couple of diagrams that are going to help explain what just occurred when we ran that command right.

So at the terminal, execute the command.

docker run hello--world

How it happened 1

That starts up that Docker client or the Dockers CLI.

Again the Docker CLI is in-charge of taking commands from you kind of doing a little bit of processing on them and then communicating the commands over to something called the Docker server and it’s that Docker server that is really in charge of the heavy lifting.

When we ran the command docker run hello-world. That meant that we wanted to start up a new container using the image with the name of hello-world, the hello-world image has a tiny little program inside of it whose sole purpose sole job is to print out the message that you see right here.

That’s the only purpose of that image.

Now when we ran that command and it was issued over to the Docker server a series of actions very quickly occurred in the background.

The Dockers server saw that we were trying to start up a new container using an image called hello-world. The first thing that the Docker server did was check to see if it already had a local copy like a copy of your personal machine of the hello-world image or hello-world file. (1st step mentioned in the above image -How it happened 1).. So the Docker server looked into something called the image cache.

But we just installed docker on our personal computers that image cache is currently empty. We have no images that have already been downloaded before. So, the image cache was empty the Docker server decided to reach out to a free service called Docker Hub. (2nd step mentioned in the above image -How it happened 1)

The Docker Hub is a repository of free public images that you can freely download and run on your personal computer.

So server reaches out to Docker Hub and said hey I’m looking for an image called hello-world.

Do you have one? Of course, the Docker Hub does

How it happened 2

So Docker server downloaded this. hello-world file and stored it on your personal computer. In this image cache where it can now be rerun at some point in the future very quickly without having to re-download it from the Docker Hub. (3rd step mentioned in the above image -How it happened 2)

Its sole purpose is to run one very specific program so the Docker server then essentially took that single file load it up into memory created a container out of it and then ran a single program inside of it and that single program’s purpose was to print out the message that you see below.

That’s what happens when you run this docker run command.

It reaches out to Docker Hub, It grabs the image and then it creates a container out of that image.

Now one thing that you’ll notice that’s kind of interesting if we run the

docker run hello-world command a second time. You’ll notice that we are not going to see the message of downloading or contain or image not found locally though we saw the first time.

And that is because we already downloaded it to our image cache on our personal computer. So the big lesson here is that the first time that you try to make use of these public images, you’re going to have to do a little bit of a download.

But then in the future after that, you can start up a container using that image much more quickly because the image has already been downloaded to your computer.

Thanks for reading and keep going. 😊

--

--

Niluka Sripali Monnankulama
Many Minds

An IT professional with over 7+ years of experience. Member of the WSO2 Identity & Access Management Team.