{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreib72ickq2u5vggw6nvw4fyq27kaod5ginkpdm2majxfix3ylegahu",
    "uri": "at://did:plc:5sgu76a53rz3n6unbykmovqy/app.bsky.feed.post/3mlogu6xoyy62"
  },
  "description": "An image layer is one immutable filesystem diff that, when stacked with the layers above and below it, forms a complete container image. Each Dockerfile instruction (FROM, COPY, RUN, ADD) typically produces one layer. Layers are content-addressable: identical layers are stored once and shared across images.\n\n\nHow layers compose\n\nAn image is described by a manifest: an ordered list of layer digests plus a config (entrypoint, env vars, labels). A container is started by stacking layers via a union",
  "path": "/engineering-glossary/image-layer-container-filesystem/",
  "publishedAt": "2026-05-12T18:40:40.000Z",
  "site": "https://sahilkapoor.com",
  "tags": [
    "Docker",
    "OCI",
    "BuildKit",
    "containerd",
    "Container Runtime"
  ],
  "textContent": "**An image layer** is one immutable filesystem diff that, when stacked with the layers above and below it, forms a complete container image. Each Dockerfile instruction (FROM, COPY, RUN, ADD) typically produces one layer. Layers are content-addressable: identical layers are stored once and shared across images.\n\n## How layers compose\n\nAn image is described by a **manifest** : an ordered list of layer digests plus a config (entrypoint, env vars, labels). A container is started by stacking layers via a union filesystem (overlayfs is the default on Linux) and overlaying a writable scratch layer on top. The container sees a single merged filesystem; writes go to the scratch layer and disappear when the container is removed.\n\n## Why layering matters\n\n  * **Caching.** A build reuses unchanged layers; only changed layers and their descendants are rebuilt.\n  * **Pull and push efficiency.** Registries store and transfer each unique layer once, regardless of how many images include it.\n  * **Determinism.** The content-addressable digest of a layer is a strong identity. Two layers with the same digest are byte-identical.\n\n\n\n## Optimisation tips reflected in real Dockerfiles\n\n  * Order instructions from most-stable to most-volatile so caches hit longer.\n  * Use `--mount=type=cache` for package manager caches instead of layer copies.\n  * Use multi-stage builds: build in a heavy stage, copy only artifacts to a slim final stage.\n\n\n\nšŸ”—\n\n**Related Terms**\nDocker, OCI, BuildKit, containerd, Container Runtime.",
  "title": "Image Layer",
  "updatedAt": "2026-05-13T19:14:44.517Z"
}