kubernetes_4
kubernetes_4
Linux kernel itself. You’ll learn about container technologies later when you
can try them out for yourself. You’ll need to have Docker installed for that,
so let’s learn how it fits into the container story.
Figure 2.4 The three main Docker concepts are images, registries and containers
Figure 2.4 shows three main Docker concepts that appear in the process I’ve
just described. Here’s what each of them is:
To understand how containers, images and registries relate to each other, let’s
look at how to build a container image, distribute it through a registry and
create a running container from the image. These three processes are shown
in figures 2.5 to 2.7.
As the next figure shows, another person can now pull the image to any other
computer running Docker and run it. Docker creates an isolated container
based on the image and invokes the executable file specified in the image.
When you run an application in a container, it sees exactly the file system
content you bundled into the container image, as well as any additional file
systems you mount into the container. The application sees the same files
whether it’s running on your laptop or a full-fledged production server, even
if the production server uses a completely different Linux distribution. The
application typically has no access to the files in the host’s operating system,
so it doesn’t matter if the server has a completely different set of installed
libraries than your development computer.
For example, if you package your application with the files of the entire Red
Hat Enterprise Linux (RHEL) operating system and then run it, the
application will think it’s running inside RHEL, whether you run it on your
Fedora-based or a Debian-based computer. The Linux distribution installed
on the host is irrelevant. The only thing that might be important is the kernel
version and the kernel modules it loads. Later, I’ll explain why.
Unlike virtual machine images, which are big blobs of the entire filesystem
required by the operating system installed in the VM, container images
consist of layers that are usually much smaller. These layers can be shared
and reused across multiple images. This means that only certain layers of an
image need to be downloaded if the rest were already downloaded to the host
as part of another image containing the same layers.
Layers make image distribution very efficient but also help to reduce the
storage footprint of images. Docker stores each layer only once. As you can
see in the following figure, two containers created from two images that
contain the same layers use the same files.
When you delete a file, it is only marked as deleted in the read/write layer,
but it’s still present in one or more of the layers below. What follows is that
deleting files never reduces the size of the image.
WARNING
Figure 2.9 If a container requires specific kernel features or modules, it may not work
everywhere