Images and Layers
Explore how Docker images consist of stacked read-only layers and learn to pull, inspect, and manage these layers using commands like docker pull, docker inspect, and docker history. Understand the role of storage drivers in presenting images as a unified filesystem and how layers update files to build efficient container images.
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 image has ...