Documentation
¶
Overview ¶
Package image extracts a rootfs into a destination directory. There are two supported sources:
- SeedDir(src, dst, exclude): copy a local directory tree into dst. Used by `init --from <dir|/>` — the production path that wraps an existing container fs into a managed rootfs.
- MaterializeTarball(src, dst): extract a .tar / .tar.gz from a local path or http(s) URL. Used by `init --tarball <path>` for demos and air-gapped setups.
Both run on stdlib only and apply the traversal-safe extractTar / walk logic in this package — there is no separate "pull from a registry" path because that would either need go-containerregistry's heavy dep tree or a fragile HTML-scraping mirror crawler. Users who want a container image should `docker export` it to a tarball and pass it via --tarball.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaterializeTarball ¶
MaterializeTarball extracts a .tar or .tar.gz at src (filesystem path or http/https URL) into destRootfs, which must already exist. The tarball stream goes through extractTar's traversal-safe handling (zip-slip / symlink-plant / hardlink-escape).
func SeedDir ¶
SeedDir copies the tree at src into dst, skipping any path in exclude (and not descending into excluded directories). It is best-effort: unreadable files (e.g. root-owned files when running unprivileged) and special files (devices, FIFOs, sockets) are skipped rather than aborting — so seeding from "/" inside a container works even as a non-root user.
If progress is non-nil it is called after each regular file with cumulative (files, bytes) counts — `init --from /` on a multi-GB image can take minutes, and a silent copy looks like a hang.
Types ¶
type Progress ¶ added in v0.2.0
Progress reports seeding progress. It is called after each regular file is copied, with the running count of files and bytes copied so far. Callers typically throttle their own rendering (it fires very frequently); pass nil to SeedDir to disable. Directories and symlinks don't trigger it (they carry ~no bytes and would just add noise to a "GB copied" readout).