Search⌘ K

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.

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.

A Docker image with stacked layers
A Docker image with stacked layers

Inspecting layers

Let’s look at all of the following ways to inspect layer information:

  • Pull operations
  • The docker inspect command
  • The docker history command

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:latest
latest: Pulling from library/ubuntu
952132ac251a: Pull complete
82659f8f1b76: Pull complete
c19118ca682d: Pull complete
8296858250fe: Pull complete
24e0251a0e2c: Pull complete
Digest: sha256:f4691c96e6bbaa99d...28ae95a60369c506dd6e6f6ab
Status: Downloaded newer image for node:latest
docker.io/node:latest
Pulling a Docker image

Each line ending with Pull complete represents a layer that Docker pulled. This image has ...