Image format
The micro-image format: manifest.json, layer indexes, chunks, boot bundles, profile.json and packages.json.
Note
Copied by node site/scripts/reference.ts from docs/format.md; do not edit it here.
A micro-image is a directory of static files: one manifest, one index per layer, and chunks addressed by hash. Any static file host can serve it; nothing runs on the server side.
<image>/
manifest.json
packages.json what is installed, and the licenses (written by the build; not read by the runtime)
layers/
<layer hex>.json layer index: the chunks of the layer, in order
chunks/
<h0h1>/<hash>.zst one chunk, zstd-compressed; the first two characters of the hash are its directory
boot/
<hash>.bin a part of a layer's boot bundle (optional)Everything except manifest.json is immutable: the name of every other file is a hash of its
content (the layer index is named after the layer digest, which covers the chunks it lists).
#manifest.json (schema 1)
{
"schema": 1,
"name": "postgres",
"tag": "17-alpine",
"arch": "aarch64",
"source": { "type": "oci", "ref": "docker.io/library/postgres:17-alpine", "digest": "sha256:..." },
"layers": [{ "digest": "sha256:...", "role": "app", "size": 291373056 }],
"config": {
"entrypoint": ["docker-entrypoint.sh"],
"cmd": ["postgres"],
"env": { "PGDATA": "/var/lib/postgresql/data" },
"workdir": "/",
"user": "0:0",
"ports": [5432],
"volumes": ["/var/lib/postgresql/data"]
},
"profile": { "probe": "tcp:5432" },
"annotations": {}
}| Field | Meaning |
|---|---|
schema | Always 1. A reader that meets another value refuses the manifest (ERR_SCHEMA). New optional fields do not change it. |
name, tag | How the runtime finds the image: name:tag, or name. |
arch | Always aarch64: the guest's user space. |
source | Where the image came from. For an OCI image: its reference, the digest the reference resolved to (an index or a manifest), and layers, the image's layers by the digest of their uncompressed tars (OCI diff_ids), bottom first. Optional. |
layers | One to three layers, bottom first. digest is the SHA-256 of the layer's erofs image, size its length in bytes, role one of base, runtime, app. url, when present, is the base URL the layer is served from; without it the layer lies next to the manifest. boot, when present, is the layer's boot bundle (below). prefetch, when present, lists chunks of the layer the image's start reads, by index in the layer index, which the runtime fetches as the image loads, a few at a time, each unless the store has it (a large base, below). removed, when present, lists chunks --slim removed, by index; removedFiles is the SHA-256 of slim/<hash>.json, which names the files in each removed chunk (below). |
config | How to run the image, from the OCI image config, with Docker's defaults for what it leaves out: user 0:0, working directory /. ports holds the TCP ports of ExposedPorts. |
profile | What the build knows about the image. Optional. probe is the readiness probe (tcp:<port>, http:<port><path> or exec:<command>). memoryMiB is the guest memory the image needs, in MiB: with --probe, untainer build measures it by starting the image once and records, from the highest peak of MemTotal - MemAvailable over its starts until the probe passes, that peak rounded up to 32 MiB, twice that, plus 32 MiB (so that the same build records the same value); --memory sets it by hand. It is a profile of the image's start, not of its work under load: an image that uses more memory once it serves requests needs more. A runtime given images up front and no memoryMiB boots with the sum of theirs; createRuntime({ memoryMiB }) overrides it. |
annotations | Free-form data for plugins, keys prefixed with the plugin's name. Readers ignore keys they do not know. |
Readers ignore fields they do not know.
#Layers
A layer is one uncompressed erofs image (mkfs.erofs -T0 -U00000000-0000-0000-0000-000000000000 --mkfs-time): file mtimes come from the layer tars, the build time and the UUID are fixed, so the
same input gives the same bytes. Compression happens per chunk, not in erofs.
The build merges every layer of an OCI image into one erofs image: one erofs image per layer tar,
stacked with overlayfs (which applies whiteouts and opaque directories), then one mkfs.erofs of
the merged tree. The root directory takes owner, mode and mtime from the topmost layer tar that has
an entry for ./, and is 0:0, 0755, mtime 0 otherwise.
With a probe (untainer build --probe ...), the image is also laid out by its start. mkfs.erofs
writes it chunk-based (--chunksize=4096: every file's data is addressed chunk by chunk, in an
index after its inode, and mkfs.erofs gives a file larger chunks where its data is contiguous
anyway). The build starts it once, sees which blocks the start reads, and moves the chunks of file
data that hold them to the front of the data area, both groups in their old order, rewriting
every chunk index to match. The tree, the metadata and the image's size do not change; the start's
data ends up in as few blocks, and so as few chunks of the layer, as it can. The layout depends
only on which blocks the start read, so the same start gives the same bytes. Readers do not need
to know: it is an ordinary erofs image. --no-layout keeps the flat layout.
The build checks the laid-out image before it uses it, apart from the code that wrote it:
fsck.erofs --extract reads every inode and file, and the guest's kernel mounts the image before
and after the layout and hashes a tar of each whole tree, which must be the same. fsck.erofs 1.9.1
lets a wrong superblock checksum and a chunk index past the end of the image through; the kernel
does not (build.vm.test.ts). When a check fails, the build warns and keeps the image as mkfs.erofs
wrote it, not laid out.
#Build profile: profile.json
What a build's starts found, next to the manifest (with --probe). The runtime does not read it.
untainer build --profile <dir>/profile.json takes it back instead of starting the image, and
makes the same image again (same manifest, layers and boot bundle), without running the probe.
{ "schema": 1, "built": "sha256:...", "blocks": [139, 140, 4302], "readOrder": ["9f86d08..."], "peakMiB": 31, "memoryMiB": 96 }| Field | Meaning |
|---|---|
built | The digest of the image's own layer as built, before the layout. The profile fits only that image; another is ERR_DIGEST. |
blocks | The 4 KiB blocks of that layer the first start read, ascending: the layout. Empty without one. |
readOrder | The chunks of the finished layer the second start read, in read order: its boot bundle, and what --slim keeps. |
peakMiB, memoryMiB | The second start's peak memory and the memory recorded for it. |
A slimmed image built from a profile is not started again to check it.
#Installed packages: packages.json
What is installed in the image and under which licenses, as its package managers recorded it,
next to the manifest. Every build writes it; the runtime does not read it. Sources: Alpine's apk
database (/lib/apk/db/installed: name, version, the L: license), Debian's dpkg status (the
installed packages, with the License: fields of /usr/share/doc/<package>/copyright) and the
global npm packages (/usr/local/lib/node_modules/*/package.json), over all the image's layers
(a later layer's file or whiteout wins). Software installed another way, such as the node
binary of the node images or postgres in the postgres images, is no package: what the image's
config says of it is listed apart, in config, as written: the variables of its environment
whose name ends in _VERSION (NODE_VERSION, PG_VERSION) and its OCI labels
(org.opencontainers.image.*). They carry no name or license of a package, and licenses
counts only packages; check the image's own documentation for the license of such software.
{
"schema": 1,
"packages": [{ "manager": "apk", "name": "musl", "version": "1.2.5-r10", "license": "MIT" }],
"config": [{ "source": "env", "key": "NODE_VERSION", "value": "24.11.1" }],
"licenses": { "MIT": 12, "GPL-2.0-only": 3 }
}| Field | Meaning |
|---|---|
packages | One entry per package: manager (apk, dpkg or npm), name, version, license as the package states it (empty when it states none; for dpkg, the copyright file's licenses joined with AND). By manager, then name. |
licenses | How many packages state each license, written as stated; (none stated) for those without. |
#Images over a base
untainer base alpine:3.24 builds a base image: one layer with role: "base", laid out and
bundled by a start of its shell (/bin/sleep, probe exec:/bin/true). A base of at most 8 MiB of
compressed chunks gets a boot bundle of the whole layer, that start's chunks first: images over it
read different parts of it, and the first one to start brings all of it for the others. A larger
base (debian:trixie-slim: 28 MB) bundles only that start, and an image over it does not take the
base's bundle: it lists the base chunks its own start reads in layers[0].prefetch, and the
runtime fetches those the store does not have when the image loads. Either way an image does not
fetch again a base chunk that another image over the same base brought into the store. A later
build of an image
whose source.layers start with a base's, the longest such among the bases it is given (by default
those in ~/.cache/untainer/bases/), builds over it: the image's first layer is the base's layer,
as it is (same digest and chunks), and its second holds only what the image adds:
every path that is new or differs from the base (type, mode, owner, mtime, xattrs, content, link
target, device, link count), the directories above them with the image's attributes, and an
overlayfs whiteout for every path of the base the image does not have. A hard link group with a
member that differs goes into the second layer whole. Laid over the base with overlayfs, as the
runtime does, the two are the image's tree. The image directory holds both layers' files; images
over the same base share its chunks, by hash. The second layer is laid out and bundled by the
image's start.
#Slim
untainer build --probe ... --slim removes, from the image's own layer (never from a base), the
content of files the image does not need, chunk by chunk. Chunks with any metadata stay: the tree,
every attribute and the small files kept inline are all still there.
--slim(--slim=files, the default): every file with data in a chunk the profiled start read is kept whole, and so is every--keep <path>(a directory keeps everything below it). Only files the start never touched go.--slim=chunks: only the chunks the start read are kept (and--keeppaths). Files the start read in part lose the rest of their content. After--slim=chunksthe image can do what its probe did and nothing that needs more: another command, or the same program doing something else, can hit a removed chunk (node:24-alpine slimmed by chunks for one server script does not start another one).
The layer index is unchanged (the layer's digest still covers every chunk); layers[].removed
lists the removed chunks and their files are not in the directory. slim/<hash>.json
(layers[].removedFiles) maps each removed chunk to the files with content in it:
{ "chunks": { "12": ["/usr/local/bin/node"] } }. A reader that needs a removed chunk fails with
ERR_SLIM, which the guest sees as an I/O error (a program that maps the file gets SIGBUS); the
container then says which files it could not read (docs/runtime.md, "Slimmed images"). The build starts the image once more and
fails with ERR_SLIM, naming the files of the chunk, when that start reads a removed chunk; a
--keep path the image does not have is ERR_SLIM too. --no-trace keeps only what --keep
names.
#Layer index: layers/<layer hex>.json
{ "chunkSize": 262144, "chunks": ["9f86d08...", null, "60303ae..."] }The layer's bytes are cut into chunks of chunkSize bytes (256 KiB by default); the last chunk is
shorter when the size is not a multiple. Each entry is the SHA-256 (hex) of the chunk's
uncompressed bytes, or null for a chunk of only zeros, which is not stored.
#Chunks: chunks/<h0h1>/<hash>.zst
The chunk's bytes compressed with zstd. A reader decompresses a chunk and checks its SHA-256
against the hash before using it; a mismatch is an error (ERR_CHUNK_HASH), never data. Chunks
are shared: two layers or images with an identical chunk store it once.
#Boot bundle: boot/<hash>.bin
The chunks a layer's start reads, in the order it first reads them, so that a cold start fetches
a few large files at once instead of one file per chunk. Optional: untainer build --probe ...
makes it from the start it profiles; a reader without it fetches chunks one by one.
"boot": { "partSize": 4194304, "parts": [{ "hash": "27032c6...", "size": 4130332 }, ...] }partSizeis the largest a part may be (the default is 4 MiB; a host's file size limit, such as jsDelivr's 20 MB, bounds it). A chunk larger than it gets a part of its own.partsare in read order. Each is the fileboot/<hash>.bin,hashbeing the SHA-256 of the whole file, andsizeits length.
A part is UNCB (4 bytes), the length of a JSON header (32-bit little-endian), the header
{"chunks": [[hash, offset, length], ...]}, then the chunks' compressed bytes one after another.
offset counts from the end of the header; each chunk is exactly the file
chunks/<h0h1>/<hash>.zst. A reader fetches every part at once, in read order, uses each chunk as
soon as its bytes have arrived, and checks it against its hash like any other chunk.