concept layer in category kubernetes

appears as: layers, layer, layers, layer, The layers
Kubernetes in Action, Second Edition

This is an excerpt from Manning's book Kubernetes in Action, Second Edition.

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 figure 2.8, two containers created from two images that contain the same layers use the same files.

You can see the layers of an image and their size by running docker history, as shown in the following listing. The top layers are printed first.

Listing 2.6 Displaying the layers of a container image
$ docker history kubia:latest
IMAGE         CREATED     CREATED BY                          SIZE
b0ecc49d7a1d  7 min ago   /bin/sh -c #(nop) ENTRYPOINT ["node"…   0B    #A
28d67701d6d9  7 min ago   /bin/sh -c #(nop) ADD file:2ed5d7753…   367B  #A
e498dabfee1c  2 days ago  /bin/sh -c #(nop) CMD ["node"]          0B    #B
<missing>     2 days ago  /bin/sh -c #(nop) ENTRYPOINT ["docke…   0B    #B
<missing>     2 days ago  /bin/sh -c #(nop) COPY file:23873730…   116B  #B
<missing>     2 days ago  /bin/sh -c set -ex && for key in 6A0…   5.4MB #B
<missing>     2 days ago  /bin/sh -c #(nop)  ENV YARN_VERSION=…   0B    #B
<missing>     2 days ago  /bin/sh -c ARCH= && dpkgArch="$(dpkg…   67MB  #B
<missing>     2 days ago  /bin/sh -c #(nop)  ENV NODE_VERSION=…   0B    #B
<missing>     3 weeks ago /bin/sh -c groupadd --gid 1000 node …   333kB #B
<missing>     3 weeks ago /bin/sh -c set -ex;  apt-get update;…   562MB #B
<missing>     3 weeks ago /bin/sh -c apt-get update && apt-get…   142MB #B
<missing>     3 weeks ago /bin/sh -c set -ex;  if ! command -v…   7.8MB #B
<missing>     3 weeks ago /bin/sh -c apt-get update && apt-get…   23.2MB#B
<missing>     3 weeks ago /bin/sh -c #(nop)  CMD ["bash"]         0B    #B
<missing>     3 weeks ago /bin/sh -c #(nop) ADD file:9788b61de…   101MB #B

Most of the layers you see come from the node:12 image (they also include layers of that image’s own base image). The two uppermost layers correspond to the second and third directives in the Dockerfile (ADD and ENTRYPOINT).

As you can see in the CREATED BY column, each layer is created by executing a command in the container. In addition to adding files with the ADD directive, you can also use other directives in the Dockerfile. For example, the RUN directive executes a command in the container during the build. In the listing above, you’ll find a layer where the apt-get update and some additional apt-get commands were executed. apt-get is part of the Ubuntu package manager used to install software packages. The command shown in the listing installs some packages onto the image’s filesystem.

Core Kubernetes

This is an excerpt from Manning's book Core Kubernetes.

The previous chapter introduced us to the topic of container filesystems, but what about containers, images, layers, and all the other jargon we use as a community to describe the stuff we run inside of Kubernetes. We have discussed and mentioned containers, images, layers, overlay, and more. Lions, tigers, and bears, oh my! In this chapter, we’ll define “the container” in the context of basic Linux primitives - the basic Linux functionality that we rely on in Kubernetes. This overview is a particularly daunting task because the container abstraction is highly overloaded in computer science.