Images and Layers
Explore the structure of Docker images as collections of read-only layers and learn methods to inspect these layers using docker commands. Understand how layers stack to form images, the impact of updating files in layers, and the role of storage drivers like overlay2. This lesson provides foundational knowledge for working with Docker images and managing containerized applications.
We'll cover the following...
As already mentioned, Docker images are a collection of loosely connected read-only layers where each layer comprises one or more files. The figure below shows an image with four layers. Docker takes care of stacking them and representing them as a single unified image.
Inspecting layers
Let’s look at all of the following ways to inspect layer information:
- Pull operations
- The
docker inspectcommand - The
docker historycommand
Run the following command to pull the node:latest image and observe it pulling the individual layers. Some newer versions may have more or less layers, but the principle is the same.
$ docker pull node:latestlatest: Pulling from library/ubuntu952132ac251a: Pull complete82659f8f1b76: Pull completec19118ca682d: Pull complete8296858250fe: Pull complete24e0251a0e2c: Pull completeDigest: sha256:f4691c96e6bbaa99d...28ae95a60369c506dd6e6f6abStatus: Downloaded newer image for node:latestdocker.io/node:latest
Each line ending with Pull complete represents a layer that Docker pulled. This ...