Skip to content

Containers

Containers package a node and all of its dependencies into a single, self-contained image. A containerized node runs identically regardless of what is installed on the host: no more “works on my machine” issues.

Use containers when you need:

  • Portability: ship a node to another machine without worrying about system dependencies.
  • Reproducibility: guarantee the same runtime environment every time.
  • Isolation: prevent conflicts between nodes that need different versions of the same library.

Peppy uses Apptainer as its container runtime. On macOS, Apptainer runs transparently inside a Lima virtual machine; no extra setup is needed.

On Linux, container nodes need three packages of the distribution, and Apptainer uses unprivileged user namespaces which may require a one-time system configuration. The installer handles this automatically, on a host and in a Docker or Podman container, but if you skipped it or installed Peppy manually you can run:

Terminal window
peppy container setup

This configures the following (through sudo for a user that is not root, and with no sudo for root):

  1. Packages: installs the package of each program of the table below that is missing. It reads the package lists first (apt-get update), so it also works in a container of a bare image, which has none.
  2. AppArmor profile (on systems that restrict unprivileged user namespaces via AppArmor): installs a profile for the apptainer and starter programs of the installation, which allows them to create user namespaces, and loads it into the kernel. When the profile already exists but is not loaded, it is reloaded without being rewritten.

The setup installs fuse2fs last, in an installation of its own. When that installation fails (the distribution of the machine does not have the package, for example), each other fix is made: the setup writes a warning and exits with 0.

In a terminal, the setup asks before it makes its fixes. When you answer n, it prints the commands and makes no change. It then exits with 1 when a container build or the daemon needs one of the fixes, and with 0 when the only fix is the installation of fuse2fs.

Peppy bundles Apptainer, and Apptainer runs three programs that come from the distribution:

ProgramPackageWhat uses itWithout it
newuidmapuidmapThe fakeroot build of a user that is not root.Each container build of a user that is not root stops. Root builds with no fakeroot, so the checks do not ask root for newuidmap.
mksquashfssquashfs-toolsEach node build: it packs the image.Each container build stops.
fuse2fsfuse2fsThe mount of an EXT3 image.Each container start writes fuse2fs not found, will not be able to mount EXT3 filesystems. The images that Peppy builds are squashfs images, which build and run without it.

A bare ubuntu:24.04 or debian:trixie image has none of the three packages.

To check the current state without making any changes:

Terminal window
peppy container status

This prints a pass/fail summary of each prerequisite and exits with code 0 (all pass) or 1 (something needs fixing). A missing fuse2fs is a warning: its line shows WARNING, and the status exits with 0. For root, the line of newuidmap shows not required.

The daemon makes the same checks at its start:

  • Without the AppArmor profile, on a system that needs one, the daemon stops. Its error gives the commands that repair each failing check.
  • Without newuidmap or mksquashfs, the daemon starts and writes a warning. Only a container build runs these two programs, so the images that the daemon has and the nodes that are not containers run. Each container build stops before it starts Apptainer, with an error that gives the command that installs each missing package. A build finds a package that you install while the daemon runs.
  • Without fuse2fs, the daemon starts.

The status also asks the kernel for a user namespace, as Apptainer does before each container build: it runs unshare --user /bin/true as the user of the builds, which is the caller of sudo when sudo runs the command. The User namespace line shows the answer:

LineMeaning
OKThe kernel gives the namespace.
FAILED (<message of unshare>)The kernel refuses the namespace, for example because a sysctl turns user namespaces off or because of the seccomp profile of a Docker container.
not requiredThe user of the builds is root, which builds with no user namespace.
not tested (<reason>)The request gives no answer for Apptainer. unshare did not run, or AppArmor refuses unshare on a system whose kernel does not have the profile unprivileged_userns (apparmor.service is stopped). Apptainer does not need that profile: it has the profile of its installation.

The setup has no fix for a namespace that the kernel refuses. peppy container status then exits with 1. peppy container setup makes the fixes of the other prerequisites, writes a warning with the message of unshare, and exits with 0. The daemon writes the same warning at its start: the nodes that are not containers run, and each container build fails.

The Node images line tells how each node gets the files of its image: mounted, or unpacked at each start for a user that is not root where a node can write to a directory on overlayfs, as in a Docker container (see Node images on overlayfs). An unpacked image is not a failure, and the status exits with 0.

To check the packages alone, add --packages:

Terminal window
peppy container status --packages

It exits with 1 when a container build stops without a package that is missing, and gives the command that installs each missing package.

Apptainer binds /etc/localtime and /etc/hosts of the host into each container, so a node has the time zone and the host names of the host. They are the bind path entries of the apptainer.conf that Peppy installs. When the host does not have the source of a bind path entry, Peppy skips that bind, and the node has what its image has at that path. A minimal host can be without /etc/localtime: the ubuntu Docker image has none until it gets the tzdata package.

Apptainer gives a node the files of its image in one of two ways: it mounts the image, or it unpacks the image and starts the node from the copy. Peppy asks for the copy (--unsquash) when these two conditions apply together:

  • The daemon is not root.
  • A directory that the node can write to is on overlayfs: /tmp, /var/tmp, the home directory of the user of the daemon, the working directory of the node (which is in the data root), the source of one of its mounts, or a path of the host that a flag of its apptainer_run_extra_args names (--bind, --mount, --home, --workdir, --overlay).

The root file system of a Docker or Podman container is on overlayfs. So a daemon of a user that is not root starts each node from a copy of its image there, unless a volume or a tmpfs holds each of these directories.

The cause is in the kernel. For a user that is not root, the mounted image is a FUSE file system in the user namespace of the node, and that namespace maps this user only. Overlayfs reads and writes a file with the credentials of the user that mounted it, and FUSE refuses a request of a user that the namespace does not map. A node that writes data of its mounted image to a file on overlayfs, for example a file that is compiled into its program, stops with Bad address (os error 14). The copy is made of files of the disk, so a node that starts from it has no such fault.

The copy has a cost:

  • Each start of a node unpacks its image with unsquashfs, which comes with the squashfs-tools package. A 400 MB image takes about one second on a fast disk.
  • The copy uses disk space while the node runs: as much as the files of the image, which can be some gigabytes for one node. It is in the data root, in tmp/container_scratch. Apptainer removes it when the node ends. Peppy removes what a node that was killed left, when the process of the node is over and before a restart of the node starts, and removes at the start of the daemon each copy that an earlier daemon left.

The Node images line of peppy container status shows which of the two ways applies:

LineMeaning
mountedApptainer mounts the image of each node.
unpacked at each start (<directories> are on overlayfs)Each node starts from a copy of its image. The line names each directory on overlayfs among /tmp, /var/tmp, the home directory and the data root. It does not name a directory that is below another one of the list, such as a data root in the home directory.

The line is for the directories that each node has. A node with a mount whose source is on overlayfs starts from a copy also when the line shows mounted. The daemon writes the same information in its log.

The status reads the data root as the command resolves it: PEPPY_HOME when the command has that variable, or else the default data root in the home directory of the user of the builds. sudo does not give the PEPPY_HOME of its caller to the command, so for a daemon with a data root that PEPPY_HOME names, give the variable to the command also (sudo PEPPY_HOME=<data root> peppy container status).

To get mounted images in a container, do one of these:

  • Put a volume or a tmpfs at each directory that the line names. For /tmp and /var/tmp of a Docker container, add --tmpfs /tmp:exec --tmpfs /var/tmp:exec to docker run, and put a volume at the home directory.
  • Run the daemon as root (see Running the daemon as root).

Apptainer mounts the image of a container in one of two ways. For a daemon that is not root, it runs the container in a user namespace and mounts the image with its bundled squashfuse_ll. For a daemon that runs as root, the kernel mounts the image. Root inside a rootless container is not this root: Apptainer uses a user namespace and squashfuse_ll there too.

A kernel mounts an image only when it is built with the compression of that image. Peppy packs each image with zstd, and some kernels cannot mount a zstd squashfs. The WSL2 kernel, which Docker Desktop on Windows also runs on, and the kernel of the NVIDIA Jetson are two of them. So a daemon that runs as root reads the compression of each image that it runs. For an image that its kernel cannot mount, Peppy passes --userns to Apptainer, and the container runs in a user namespace as it does for every other user. Peppy reads the kernel configuration from /proc/config.gz, then from /boot/config-<kernel release>, and looks for the line of the compression: CONFIG_SQUASHFS_ZSTD=y for zstd.

In that user namespace:

  • A node has none of the capabilities of the real root. It cannot, for example, take a real-time priority.
  • Root has its rights on the files of root only. The Peppy installation, the working directory of the node and the source of each mount of the node must be in directories that root owns, that a group of the daemon can enter, or that every user can enter, and not below the private home directory of another user. When the installation is not, the daemon starts and writes a warning in its log. A container with one of these paths out of reach stops at its start with an error that names the directory and how to open it. A process node does not use the user namespace, so it works. A build works too: only the prune of the uv cache after the build of a Python node runs the image, and with a path out of reach the build output says that the cache is not pruned.

A container whose image the kernel mounts runs without a user namespace, with the capabilities of the real root. On a kernel that mounts zstd squashfs, this is each container of a root daemon. On a kernel that does not, a node that needs these capabilities packs its image with a compression that the kernel mounts, with apptainer_build_extra_args: ["--mksquashfs-args", "-comp gzip"] (see Extra runtime arguments).

Pass the --container flag to peppy node init:

Terminal window
peppy node init --toolchain uv --container my_node "A node that runs in an Apptainer container."

This generates the same project scaffolding as a regular node, plus an apptainer.def file that describes how the container image is built.

A container node includes a container block inside its execution section instead of the usual build_cmd and run_cmd fields. The two are mutually exclusive: a node is either a container node or a process node, never both.

peppy.json5
{
peppy_schema: "node/v1",
manifest: {
name: "my_node",
tag: "v1",
description: ["A node that runs in an Apptainer container."],
},
interfaces: {},
execution: {
language: "python",
container: {
def_file: "apptainer.def",
},
}
}

The def_file field points to the Apptainer definition file relative to the node root. You can rename or relocate it as long as def_file matches.

Compare this with a standard process node, which defines build_cmd and run_cmd instead:

peppy.json5 (process node)
{
peppy_schema: "node/v1",
manifest: {
name: "my_node",
tag: "v1",
description: ["A node that runs as a process on its machine."],
},
interfaces: {},
execution: {
language: "python",
build_cmd: ["uv", "sync", "--no-editable"],
run_cmd: ["./.venv/bin/python", "-m", "my_node"]
}
}

Container nodes don’t need build_cmd or run_cmd; the definition file takes care of both building and running the node.

The generated definition file is a standard Apptainer definition file. Here is what peppy node init --container generates:

apptainer.def
Bootstrap: docker
From: peppybot/python-uv-base:latest
%labels
Name my_node
Version v1
%environment
export PATH="/opt/my_node/.venv/bin:$PATH"
%files
. /opt/my_node
%post
set -eux
export DEBIAN_FRONTEND=noninteractive
export UV_PYTHON_INSTALL_DIR=/opt/uv-python
cd /opt/my_node
uv python install
uv sync --no-editable
%runscript
cd /opt/my_node
exec ./.venv/bin/python -m my_node

Each section serves a specific purpose:

SectionPurpose
Bootstrap / FromBase image to build from (Ubuntu 24.04 by default)
%labelsMetadata embedded in the image
%environmentEnvironment variables set when the container runs
%filesCopies the node source into the image at /opt/<node_name>
%postBuild steps: install system packages, toolchains, and compile the node
%runscriptEntry point executed when the container starts

Adding a container node works the same as a regular node: first stage it, then build.

Terminal window
peppy node add ./my_node
peppy node build my_node:v1

You can also combine both steps with peppy node add ./my_node --build (shorthand -b). If you’ve just edited peppy.json5, add --sync/-s as well, e.g. peppy node add ./my_node -sb to sync, add, and build in one shot.

Under the hood, Peppy runs apptainer build during the build phase to produce a .sif (Singularity Image Format) file. This replaces the build_cmd step used by process nodes; the entire build happens inside the container according to the %post section of the definition file.

The resulting .sif file is stored under ~/.peppy/built_nodes/<name>_<tag>/, named after the fingerprint of the staged sources (see Build caching), and is ready to be started.

Starting a container node also uses the same command:

Terminal window
peppy node run my_node:v1

Peppy runs the .sif image with apptainer run and a clean environment: the daemon’s own environment is not inherited. The environment of the instance (the forwarded environment on the coordinator, the values of its env_from_launch and its declared env_vars, minus HOME, which is dropped) and PEPPY_RUNTIME_CONFIG are passed in explicitly, and the image’s %environment section applies as usual. Each one reaches apptainer as an APPTAINERENV_ variable, never on a command line: on Linux in the environment of the apptainer process, and on macOS on the standard input of the command in the Lima VM, whose shell exports each one before it starts apptainer.

The container executes the %runscript section, which runs the compiled binary (Rust) or the Python module entry point.

What a container node sees of the data root

Section titled “What a container node sees of the data root”

The data root of Peppy (~/.peppy, or PEPPY_HOME) holds the keys that the clients of the daemon sign their calls to it with, and the machine certificate (see The senders of the calls to a daemon). A container node does not see it: the daemon mounts an empty directory over the data root, and over that directory the container sees its own working directory, its own runtime configuration and its own key file, and nothing else of the data root. Apptainer binds the home directory of the user into the container, so a node keeps its caches and its other files there.

By default, a container is isolated from the host filesystem. Use mount_paths to bind-mount host directories into the running container, useful for sharing datasets, persisting output, or exposing device files.

Add a mount_paths array to the container block inside execution in peppy.json5:

peppy.json5
{
peppy_schema: "node/v1",
manifest: {
name: "my_node",
tag: "v1",
description: ["A node that runs in an Apptainer container."],
},
interfaces: {},
execution: {
language: "python",
container: {
def_file: "apptainer.def",
mount_paths: [
"/data/models:/opt/models:ro",
"/tmp/my_node_output:/output:rw"
]
},
}
}

Each entry follows the format host_path:container_path[:options]:

FormatExampleBehaviour
host_path"/data/models"Mounted at the same path inside the container
host_path:container_path"/data/models:/opt/models"Mounted at a different path inside the container
host_path:container_path:options"/data/models:/opt/models:ro"Mounted with explicit options (ro for read-only, rw for read-write)

host_path may start with ~, which expands to the home directory of the user running the daemon on the machine where the instance runs. In a federated launch, each machine expands ~ against its own home, so a single manifest works across machines with different usernames ("~/.cache/my_node:/cache:rw"). The ~user form is not supported and is rejected while the launch is being validated, before any stack is replaced. Only the host side is expanded: a ~ in container_path is passed to the container verbatim.

A source under /dev with no remap (no destination, or a destination equal to the source) is passed through rather than bound: host devices reach the container through Apptainer’s device mount, and only a remapped device bind emits an explicit --bind.

A missing mount source is created on the host as a directory before the container starts, and a warning names each auto-created path, so a typo in a file bind shows up as an unexpectedly created empty directory. Sources under the host runtime trees (/dev, /proc, /run, /sys) are used as-is and never created.

Mount paths can reference runtime parameters using the ${parameters:<path>} syntax. This lets each node instance mount a different host path based on its configuration.

peppy.json5
{
peppy_schema: "node/v1",
manifest: {
name: "uvc_camera",
tag: "v1",
description: ["The driver of a UVC camera, in an Apptainer container. It needs a UVC camera at the device path that its parameter gives."],
},
interfaces: {},
execution: {
language: "rust",
parameters: {
device_path: "string",
},
container: {
def_file: "apptainer.def",
mount_paths: [
"${parameters:device_path}:/dev/video0:rw"
]
},
},
}

When the node runs, ${parameters:device_path} is replaced with the actual value provided in the deployment configuration. For example, if the instance supplies device_path: "/dev/video2", the resulting bind mount is /dev/video2:/dev/video0:rw.

For nested parameters, use dot notation:

peppy.json5 (nested example)
{
// ...
execution: {
// ...
parameters: {
video: {
device_path: "string",
frame_rate: "u16",
},
},
container: {
def_file: "apptainer.def",
mount_paths: [
"${parameters:video.device_path}:/dev/video0:rw"
]
},
},
// ...
}

Every peppy node build, including the ones peppy stack launch and peppy stack build run for each deployment, fingerprints the staged node tree before building: the node sources, peppy.json5, the def file, the generated .peppy/ code and the vendored peppylib, mixed with the peppy version, the platform of the artifact and the artifact kind. The artifact is stored under that fingerprint, and the file of a container node also names its platform (linux-amd64 or linux-arm64):

~/.peppy/built_nodes/<name>_<tag>/<fingerprint>.linux-<arch>.sif container node
~/.peppy/built_nodes/<name>_<tag>/<fingerprint>.tar.zst process node

When the fingerprint already has an artifact on disk, the build reuses it instead of running apptainer build (or build_cmd for a process node), and the build log carries one line:

Reusing cached build of my_node:v1 (fingerprint 3f9a1c2e5d7b8a4f) at ~/.peppy/built_nodes/my_node_v1/3f9a1c2e5d7b8a4f.linux-amd64.sif

The cache is a plain directory tree keyed by content, so it survives daemon restarts and reboots, and a disk prepared on one machine carries its built nodes to every machine that boots from it with the same peppy version, OS and architecture. A process node’s archive also embeds what the host toolchain produced, which the fingerprint does not cover, so those machines need a compatible build environment as well. Each node identity keeps one artifact for each platform: a build whose fingerprint differs replaces the previous one of its platform. A node that an oci repository supplies is pulled, not built: its image is stored as ~/.peppy/built_nodes/<name>_<tag>/<sha256 of the image>.linux-<arch>.sif.

Pass --rebuild to peppy node build, peppy stack launch or peppy stack build to build from the staged sources even when a matching artifact exists; the result replaces it. Use it when something outside the fingerprint changed:

  • A floating base image tag (From: peppybot/rust-cargo-base:latest) that now resolves to a different image. Pin the image with @sha256:<digest> in the def file to make base image changes part of the fingerprint.
  • For a process node, the host toolchain or the environment build_cmd runs with.

--rebuild is independent of --force, which cancels an in-flight build of the same node.

Rust and Python container builds reuse a shared cache across builds, without any per-node configuration. The daemon bind mounts ~/.peppy/cache/container_build into the build at /peppy-cache and points the %post toolchain at it.

A Rust container build gets:

  • The crates.io registry in cargo-home/, via CARGO_HOME, so dependencies are downloaded once instead of on every build.
  • sccache caches rustc invocations in sccache-cache/<arch>/, via RUSTC_WRAPPER and SCCACHE_DIR, so unchanged crates are not recompiled. Each architecture has its directory, since the output of a compiler of one architecture is no use to a build of the other. The executable ships inside peppybot/rust-cargo-base, so nothing needs to be installed on the host, on Linux or macOS; the wrapper is activated only for defs that bootstrap from that image.

A Python container build gets:

  • The packages uv downloads and builds in uv-cache/, via UV_CACHE_DIR, so a rebuild installs every package it already downloaded from the cache.
  • The interpreter archives uv python install downloads in uv-python/, via UV_PYTHON_CACHE_DIR, so each Python version is downloaded once.
  • UV_LINK_MODE=copy: uv copies the files of the packages it installs from its cache into the image. The cache is a bind mount, where uv cannot hard-link into the image, and a copy keeps every file of the image independent of the host cache.

Both get PEPPY_DOWNLOAD_CACHE, which names /peppy-cache/downloads, a directory for the files a %post downloads. No tool reads it on its own: a def that pins a download by its sha256 looks the file up there under that checksum before it downloads it, and stores what it downloaded there once the checksum matches. A rebuild then reaches the network only for a pin it has not seen yet.

A def tests for PEPPY_DOWNLOAD_CACHE, not for /peppy-cache: the variable is set only when the cache is bind mounted, while /peppy-cache also exists as a plain directory of the base image, where anything written ends up in the built image. Because the directory is shared, a def checks a cached file against its pin before it uses it, and stores a file under a temporary name before it renames it, so concurrent builds never read a partial file:

Terminal window
# fetch_pinned URL SHA256 DEST
fetch_pinned() {
local cached="${PEPPY_DOWNLOAD_CACHE:-}/$2" part
if [ -n "${PEPPY_DOWNLOAD_CACHE:-}" ] && [ -f "$cached" ] \
&& echo "$2 $cached" | sha256sum -c --status; then
cp "$cached" "$3"
return
fi
curl -fsSL --retry 3 --retry-all-errors -o "$3" "$1"
echo "$2 $3" | sha256sum -c -
[ -n "${PEPPY_DOWNLOAD_CACHE:-}" ] || return 0
part=$(mktemp "$PEPPY_DOWNLOAD_CACHE/.$2.XXXXXX") \
&& cp "$3" "$part" && mv -f "$part" "$cached" \
|| { rm -f "$part"; echo "warning: $1 not stored in the download cache"; }
}

Both also get PEPPY_NODE_BUILD_CACHE, which names /peppy-cache/nodes/<arch>/<name>_<tag>: a directory of the node being built for the architecture of the build, which no build of another node or of another architecture uses. Peppy never reads it. A def keeps there what its next build can use, such as a part of the image that it builds again only when the inputs of that part change, stored under a hash of those inputs. A build of the node can start while an earlier one still ends (after a --force build, say), so a def stores a file there under a temporary name and then renames it, as with the downloads. Nothing prunes the directory: a def that stores a new entry removes the entries it no longer needs.

Caching is best effort and never fails a build: when the main directory of the cache of a build (cargo-home/ or uv-cache/) is unavailable, the build runs exactly as it would without caching, and when another part is unavailable, the build runs without that part only. Set PEPPY_NO_CONTAINER_BUILD_CACHE=1 in the daemon’s environment to disable caching entirely. The daemon also skips the cache for one build when the def file or apptainer_build_extra_args mention one of the markers of the build’s language:

LanguageMarkers
Rustrustup (installing it in %post is incompatible with the CARGO_HOME override), CARGO_HOME, RUSTC_WRAPPER, SCCACHE_DIR, SCCACHE_SERVER_PORT
PythonUV_CACHE_DIR, UV_PYTHON_CACHE_DIR, UV_LINK_MODE, --link-mode (the flag of uv overrides UV_LINK_MODE)

A Python def that installs rustup, to build a Rust extension for example, keeps its uv cache: the Python cache sets no cargo variable.

After each Python container build that uses the cache and succeeds, the daemon prunes uv-cache/ with uv cache prune, run with the uv of the image that the build wrote. Each build stages the local projects of the node again (the node itself, and .peppy/libs/peppylib with its native extension), so uv builds them again and keeps every earlier build of them, which no later build uses. The prune removes these. It also removes each file or directory at the top of uv-cache/ that is not a cache directory of uv, and each archive in archive-v0/ that no cache entry names; other files in the cache directories of uv stay. A line of the build output gives the result, for example Container build cache: uv cache pruned: Removed 15 files (6.8MiB).

A failed prune does not fail the build. A build that fails or is cancelled does not prune. A build prunes only when no other Python container build uses the cache; else a later build that succeeds prunes it. A Python build that starts while another build prunes waits until the prune ends, and a line of the build output says so: Container build cache: waiting for another build to prune the uv cache.

The prune runs the first uv on the PATH of the image that is not in a Python virtual environment, as %post does not see the virtual environment that a %environment puts on PATH. There is no prune when the image has no such uv, and the daemon stops a prune that runs for 30 seconds. Where Apptainer unpacks the image before the prune (see Node images on overlayfs), the prune has 10 minutes more, for the time that the extraction takes. uv also removes the entries of a cache layout that is not its own: nodes whose images have uv versions with different cache layouts remove each other’s entries.

Python builds download their packages from PyPI. When PyPI is slow from the host, set pypi_mirror in the daemon configuration to the packages base URL of a PyPI mirror, and restart the daemon:

pypi_mirror: "https://pypi.tuna.tsinghua.edu.cn/packages/",

Before a Python node builds, a container node or a process node alike, the daemon reads each uv.lock in the staged copy of the node. It collects the files that the lock pins by sha256 for packages from a registry, at a URL below https://files.pythonhosted.org/packages/. It asks the mirror for each of these files with a HEAD request, 8 at a time, and puts the mirror in the URL of each file that the mirror has with the size the lock records. Every other file keeps its PyPI URL, so a file that the mirror does not have yet still comes from PyPI.

Only the staged copy changes: the node sources stay as they are, and the build artifact cache keys the build by the staged tree as it was before the change, so a build finds the same artifact with and without a mirror. The image or the archive of the node holds the rewritten uv.lock.

A mirror that you do not control is safe: uv checks each file it downloads against the sha256 in the lock, and the lock comes from the repository of the node. A mirror can make a build slow or make it fail, but it cannot change what the build installs. uv accepts the rewritten lock with uv sync, uv sync --locked and uv sync --frozen, and the uv cache stays valid when you change or remove the mirror. Packages from other sources (a direct URL, git, a path), registry files on another host (such as the files that download.pytorch.org serves itself), and files that no lock pins do not use the mirror. Files that no lock pins include the build requirements uv installs to build the node and its .peppy/libs projects (such as hatchling and setuptools), the Python interpreter, GitHub release assets, apt packages and base image layers.

The presence check uses the proxy that ALL_PROXY, HTTPS_PROXY or HTTP_PROXY names in the environment of the daemon (HTTP or SOCKS), and skips the hosts in NO_PROXY, as uv does.

Each build that uses the mirror shows one line per uv.lock, which names the lock, as the build may not read every lock of the node (the lock of a test project, for example):

PyPI mirror: pypi.tuna.tsinghua.edu.cn; uv.lock: 868 of 870 locked files from the mirror, 2 from files.pythonhosted.org

A check that takes more than a few seconds also shows how many files it checked. When the mirror does not answer, when a uv.lock cannot be read or written, or when the check cannot run, the build shows a warning and downloads the files concerned from PyPI. A mirror that answers the HEAD request for a file but then fails to send the file makes uv fail the build: build again, or set pypi_mirror back to null.

A packages base URL is the URL under which a mirror keeps the files of PyPI with the path layout of https://files.pythonhosted.org/packages/: the path of a file after the packages base URL is the same on both. It is not the index URL of the mirror, which ends with /simple/. Some mirrors and their packages base URL:

MirrorLocationPackages base URL
OSSONetherlandshttps://pypi.osso.nl/packages/
YandexRussiahttps://mirror.yandex.ru/pypi/web/packages/
Tsinghua University (TUNA)Chinahttps://pypi.tuna.tsinghua.edu.cn/packages/
USTCChinahttps://mirrors.ustc.edu.cn/pypi/packages/
Nanjing UniversityChinahttps://mirror.nju.edu.cn/pypi/web/packages/
SJTUChinahttps://mirror.sjtu.edu.cn/pypi-packages/
Huawei CloudCDNhttps://repo.huaweicloud.com/repository/pypi/packages/

To check that a mirror has a file, take the URL of the file from your uv.lock, replace https://files.pythonhosted.org/packages/ with the packages base URL of the mirror, and send a HEAD request that follows redirects. The mirror has the file when the last answer is 200 with a Content-Length equal to the size in the lock, and does not come from files.pythonhosted.org: some mirrors redirect every file to PyPI, and the daemon then keeps the PyPI URL:

Terminal window
curl -sIL https://pypi.tuna.tsinghua.edu.cn/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl

A mirror can be hours behind PyPI, and PyPI is fast from most places, so set a mirror only when PyPI is slow from the host.

You can pass additional command-line arguments directly to Apptainer or Lima using apptainer_build_extra_args, apptainer_run_extra_args, and lima_shell_extra_args in the container block inside execution.

peppy.json5
{
peppy_schema: "node/v1",
manifest: {
name: "my_node",
tag: "v1",
description: ["A node that runs in an Apptainer container."],
},
interfaces: {},
execution: {
language: "python",
container: {
def_file: "apptainer.def",
apptainer_build_extra_args: ["--no-setgroups"],
apptainer_run_extra_args: ["--no-setgroups"],
},
}
}
FieldPurpose
apptainer_build_extra_argsExtra flags appended to apptainer build (e.g., ["--no-setgroups"])
apptainer_run_extra_argsExtra flags appended to apptainer run (e.g., ["--no-setgroups"])
lima_shell_extra_argsExtra flags passed to limactl shell whenever a build runs in a Lima VM: every container build on macOS, and on Linux a build for another architecture (peppy node publish --platforms, peppy stack build --publish --platforms), which runs in an emulated VM. Ignored for a native Linux build of this machine’s own platform

All fields are optional and default to an empty list when omitted.

Peppy packs every image it builds with zstd at level 3 (--mksquashfs-args "-comp zstd -Xcompression-level 3"), which packs a node image about ten times faster than Apptainer’s default gzip, at the same size. The extra build arguments come after that flag, and Apptainer reads the last --mksquashfs-args, so apptainer_build_extra_args: ["--mksquashfs-args", "-comp xz"] packs the image with xz.

A node that renders or computes on the host’s NVIDIA GPU passes apptainer_run_extra_args: ["--nv"]: Apptainer then binds the host’s driver libraries (CUDA, EGL, GLX, NVML) into the container at start. Apptainer’s own list of these libraries covers NVIDIA’s desktop driver. The L4T driver of a Jetson board loads more libraries, and the set changes from one L4T release to the next. Each L4T release lists them in its container manifest, the *.csv files in /etc/nvidia-container-runtime/host-files-for-container.d. Before it starts a --nv node, peppy adds every shared library of that manifest to the list of the bundled Apptainer. So the same node configuration renders and computes through the GPU on a desktop and on a Jetson.

On macOS, Apptainer is not natively available. Peppy bundles a Lima virtual machine that runs Apptainer inside a lightweight Linux guest. This is handled transparently and requires no additional installation or configuration; peppy node commands work the same way on macOS and Linux, with one exception: mount sources under the host runtime trees (/dev, /proc, /run, /sys) are refused, since a device plugged into the Mac cannot be forwarded into the Linux guest. The guest has the architecture of the Mac, so a node runs as a linux/arm64 container on a Mac with Apple silicon. A publish for another architecture builds in a second VM, which emulates that architecture with QEMU, on macOS and on Linux.

The generated apptainer.def is a starting point. You can modify it freely to fit your needs. Common customizations include:

Add packages to the %post section:

%post
apt-get update
apt-get install -y --no-install-recommends \
libopencv-dev libudev-dev
rm -rf /var/lib/apt/lists/*

The Ubuntu snapshot of the peppy base images

Section titled “The Ubuntu snapshot of the peppy base images”

In the peppy base images (peppybot/python-uv-base, peppybot/rust-cargo-base), apt reads the Ubuntu packages from one dated snapshot of the Ubuntu archive, which the Ubuntu snapshot service serves. The snapshot is the archive as it was one hour before the build of the base image started, and its package index and package files do not change. While the snapshot service answers, a node build on a peppy base image gets this from it:

  • Two builds of the node on the same base image install the same versions of the Ubuntu packages.
  • The build upgrades no package of the base image: each package of the image is at its version in the snapshot.
  • The node has the Ubuntu security updates up to the date of the snapshot, not up to the day of its build. A newer base image reads a newer snapshot. Pass --rebuild to build a node on it (see Build artifact cache).

For a file that the snapshot service does not serve (it does not answer, or it answers with an error), apt asks the regular Ubuntu mirror: archive.ubuntu.com on linux/amd64, ports.ubuntu.com on linux/arm64. A build that the snapshot service does not answer at all reads the current state of the archive, as a build on another Ubuntu image does: it is slower, by about 30 seconds for each apt-get command when the service does not answer, and it can install newer versions than the snapshot and upgrade packages of the base image.

The date of the snapshot is a UTC time in the form YYYYMMDDTHHMMSSZ. The image holds it in its bot.peppy.apt-snapshot label:

Terminal window
docker pull peppybot/python-uv-base:latest
docker inspect --format '{{ index .Config.Labels "bot.peppy.apt-snapshot" }}' peppybot/python-uv-base:latest

Inside a build, /etc/apt/peppy-ubuntu-mirrors.txt lists the snapshot first and the regular mirror second, and each line that apt prints for a package names the source it downloads the package from:

Get:1 https://snapshot.ubuntu.com/ubuntu/20261110T073833Z noble/main amd64 libudev-dev amd64 255.4-1ubuntu8 [22.0 kB]

apt reads a repository that the definition file adds itself (a PPA, the repository of a vendor) as the definition file names it: the packages of that repository do not come from the snapshot. A definition file with another base image reads the sources of that image.

Swap the From line to use a different base:

Bootstrap: docker
From: nvidia/cuda:12.4.0-devel-ubuntu24.04

Using a pre-built base image for faster builds

Section titled “Using a pre-built base image for faster builds”

Every peppy node add runs the full %post section from scratch, installing system packages, toolchains, and compiling dependencies each time. For nodes with heavy dependencies this can be slow.

You can speed things up by baking those slow steps into a custom Docker image and using it as your base. The first build pays the cost once; every subsequent node add starts from the cached image and only rebuilds your application code.

  1. Create a Dockerfile with the dependencies your node needs:

    Dockerfile
    FROM ubuntu:24.04
    RUN set -eux \
    && export DEBIAN_FRONTEND=noninteractive \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
    ca-certificates curl python3 python3-venv \
    && rm -rf /var/lib/apt/lists/* \
    && curl -LsSf https://astral.sh/uv/install.sh | sh
  2. Build and push the image to a registry your build machine can reach:

    Terminal window
    docker build -t my-registry/my_node-base:latest .
    docker push my-registry/my_node-base:latest
  3. Point your apptainer.def at the new image and remove the steps that are already baked in:

    apptainer.def
    Bootstrap: docker
    From: my-registry/my_node-base:latest
    %labels
    Name my_node
    Version v1
    %environment
    export PATH="/root/.local/bin:/opt/my_node/.venv/bin:$PATH"
    %files
    . /opt/my_node
    %post
    set -eux
    cd /opt/my_node
    uv sync --no-editable
    %runscript
    cd /opt/my_node
    exec ./.venv/bin/python -m my_node

Now peppy node add only runs the application-specific build steps; package installation and toolchain setup are already in the base image.

On Linux, a build reads registry credentials from the same file Apptainer reads: $APPTAINER_AUTH_FILE when it is set, else ~/.apptainer/docker-config.json (written by apptainer registry login) when it exists, else ~/.docker/config.json (written by docker login). Log in to the registry that holds your base image with either tool before you build.

Peppy gives Apptainer a copy of that file without the https://index.docker.io/v1/access-token and https://index.docker.io/v1/refresh-token entries that Docker’s browser login adds. These entries hold Docker’s own session tokens, not registry passwords, and Apptainer would otherwise use one of them at random in place of your Docker Hub credential. Peppy writes the copy before each build, so a new docker login applies to the next build without a daemon restart. If Peppy cannot read or parse the file, the build fails and names the file.

On macOS, builds run inside the Lima guest, so they use the credential files in the guest user’s home directory.

Add variables to the %environment section so they are available at runtime:

%environment
export PATH="/opt/my_node/.venv/bin:$PATH"
export PYTHONUNBUFFERED=1