Articles

Container images, registries, volumes and networks

Layers, tags and mounts: what a container image is and where its data actually lives.

Reading: 5 minServer & Virtualization

Article cover: Container images, registries, volumes and networks

A container image is not a disk. It is an ordered stack of layers — each a content-addressed archive of filesystem changes — plus a small config saying how to run the result. Running a container does not copy the image: the layers are stacked read-only and one thin writable layer is added on top, and that layer dies with the container. If data must outlive it, the answer is a volume or a bind mount: a directory on the host, never the image.

What an image really is: manifest, config and layers

The Open Container Initiative (OCI) image specification builds an image from four parts: an image manifest, an optional image index, a set of filesystem layers, and a configuration. The manifest is the map — it “contains metadata about the contents and dependencies of the image including the content-addressable identity of one or more” layer archives — while the configuration “includes information such as application arguments, environments, etc.”. A manifest “provides a configuration and set of layers for a single container image for a specific architecture and operating system”; the image index is the “fat manifest” pointing at several, so one name resolves per platform. Since “Each image’s ID is given by the SHA256 hash of its” configuration JSON, one changed byte in one layer yields a different image.

Content addressing: descriptors, digests and tags

The content descriptor ties the parts together: a media type, a digest and a size, since “A Content Descriptor includes the type of the content, a content identifier”. The digest “acts as a content identifier” — a collision-resistant hash, so identical content always has the same name — and untrusted content “SHOULD be verified against this digest when consumed via untrusted sources”. A tag is not content but “a custom, human-readable pointer to a manifest. A manifest digest may have zero, one, or many tags referencing it”.

image (read-only, content-addressed)              registry
  layer 3   sha256:c3…                            pull: manifest + blobs
  layer 2   sha256:b2…
  layer 1   sha256:a1…  (base)
        │  unpacked and stacked
        ▼
container root filesystem
  ┌───────── writable layer (one per container) ─────────┐  → dies with the container
  ├───────── layer 3  (read-only) ───────────────────────┤
  ├───────── layer 2  (read-only) ───────────────────────┤
  └───────── layer 1  (read-only, base) ─────────────────┘
        ▲                                   ▲
        │ named volume                      │ bind mount
   Docker-managed dir on the host      any host path

The registry: pull, push and the blobs

A registry is “a service that handles the required APIs defined in this specification”; a repository is “a scope for API calls on a registry for a collection of content”. It stores blobs: “the binary form of content that is stored by a registry, addressable by a digest”. Pull is “the act of downloading blobs and manifests from a registry”, retrieving “the manifest and one or more blobs”. Push reverses it: “the blobs making up the object are uploaded first, and the manifest last.” Verification is built in: “After each layer is downloaded, the engine verifies the digest of the layer, ensuring that the content matches that specified by the manifest.” Since content is named by its own hash, identical layers are stored once.

The container filesystem: one writable layer over read-only ones

Running a container unpacks the layers and adds one writable layer on top. “By default all files created inside a container are stored on a writable container layer that sits on top of the read-only, immutable image layers.” That layer “is unique per container”, and: “Data written to the container layer doesn’t persist when the container is destroyed.” The stack is presented as one filesystem by a union filesystem (on Linux, usually OverlayFS) whose driver “provides a union filesystem, using the Linux kernel” — not free, since it “reduces performance as compared to using volumes, which write directly to the host filesystem”. A removed path becomes a whiteout, “an empty file with a special filename that signifies a path should be deleted”, hiding a file from a lower layer.

Where the data lives: volumes, bind mounts and tmpfs

Persistence comes from outside the image. Volumes are “persistent data stores for containers, created and managed by Docker”: a volume is “stored within a directory on the Docker host”, and “this directory is what’s mounted into the container”. Their lifecycle is separate: “A volume’s contents exist outside the lifecycle of a given container. When a container is destroyed, the writable layer is destroyed with it.” They are “the preferred mechanism for persisting data generated by and used by Docker containers”. A bind mount mounts a host path directly, but “Since they aren’t isolated by Docker, both non-Docker processes on the host and container processes can modify the mounted files simultaneously”. A tmpfs mount “stores files directly in the host machine’s memory”, so it is ephemeral by construction.

Container networks and their drivers

The container’s network is assembled from outside too. “A container only sees a network interface with an IP address, a gateway, a routing table, DNS services, and other networking details” — it has no idea what kind of network it is on. On Linux, Docker creates a single “default bridge” network and puts a container there unless told otherwise; there, containers reach each other only by IP, while on a user-defined network they “can communicate with each other using container IP addresses or container names”. The driver fixes the topology: “bridge” is “The default network driver”; “host” will “Remove network isolation between the container and the Docker host”; “none” will “Completely isolate a container from the host and other containers”; overlay, ipvlan and macvlan complete the set, with macvlan making containers “appear as devices on the host’s network”.

From image to running process, and the error to avoid

Something must turn a pulled image into a running process. containerd is “an industry-standard container runtime” that “can manage the complete container lifecycle of its host system: image transfer and storage, container execution and supervision, low-level storage and network attachments”. Below it sits runc, which “is a CLI tool for spawning and running containers on Linux according to the OCI specification”; the unpacked image becomes the OCI bundle it starts. The error this corrects is one assumption: that data written inside a container is the container’s data. An image is read-only and content-addressed — no place to write. A container is one running instance plus a disposable writable layer, and deleting it deletes the layer. A volume is the only one built to survive, and it lives on the host.

Level and prerequisites

L4 — operational depth on containers: the image, registry, volume and network model itself, not the tooling around it. Prerequisites are the process and supervisor model — Processes, services and system management (L1) and systemd: units, targets and controlling services (L2) — because a container is a supervised set of processes, not a service manager. Namespaces and capabilities for isolation, the three command-line tools, and health and restart policies are the neighbouring sheets.

Where to go next

  • Server & Virtualization — the area this sheet belongs to; its Operating systems node is operating-systems.
  • The companion sheets in this batch: the three tools (Docker, Podman, Compose); health checks, restart policies and logging; rootless containers, capabilities and isolation.
  • The L1 and L2 sheets on processes and on systemd, for what a container is not.
  • Beyond L4: orchestrators and distributed scheduling, which build on this model.

References

Nodrius Field Kit — cover

Get the Nodrius Field Kit

Enter your email and we'll send you the complete Field Kit: eight technical resources in one download.

Your email address is sent to Nodrius and used to deliver the Field Kit to you by email. Marketing messages are separate and optional: the checkbox does not affect your download, and you are only added to our updates list if you tick it. Privacy Policy.

Privacy & cookies

This site does not use cookies, analytics or tracking, and it does not profile you. There is nothing technical to switch off, so Accept and Reject change nothing about how the site works: either choice lets you browse everything normally.

The only difference is what your browser remembers: two entries in local storage — your choice here, so this notice is not shown again, and a marker that the Field Kit offer has already been made — so the offer is presented once and not on every page. They contain no identifier, they are not shared with anyone, and the site sets no cookie for either.

What we do with your data
How your email address is used when you ask for a Resource, how long it is kept and which rights you have — in the Privacy Policy.
What the site stores in your browser
Two entries in local storage — your choice on this notice and whether the Field Kit offer has been shown — and no cookies, no session storage, no third-party content: in the Cookie Policy.