Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / container-and-oci-runtime

Container and OCI runtime

ArcBox runs container workloads in one Linux System VM. The host daemon presents a Docker-compatible control surface, the guest agent prepares and starts the container runtime, and the guest runtime creates the workload process and its filesystem. Engine-managed VM state and runtime readiness remain separate so a running VM is not treated as a ready container service.

Runtime purpose

The container runtime provides the execution layer for Linux workloads. It brings up containerd and dockerd inside the System VM, then uses their normal container and image services to materialize root filesystems, start processes, and report workload state. The host keeps the Docker-facing control path while the guest owns process execution.

The runtime uses one System VM rather than a separate VM for each container. Native arm64 workloads run directly in that guest. linux/amd64 workloads use FEX through the guest's binfmt_misc support, and ArcBox rejects such work when that translator is not available instead of selecting another VM.

References: app/…/routing.rs• L1-13 app/…/routing.rs• L64-123

Runtime materialization

Runtime materialization turns a verified boot asset generation into an executable guest-local runtime. The agent selects the current architecture, checks the generation manifest and asset digests, copies the required executables to persistent storage, and publishes one stable path for the runtime services. A complete generation can be reused after a guest restart.

The materialization step is separate from container image materialization. It installs the programs that run containers. containerd and dockerd then use their own image and snapshot stores to provide each container's filesystem.

flowchart LR
    Manifest[Verified runtime manifest] --> Select[Select guest architecture]
    Assets[Boot runtime assets] --> Verify[Copy and verify assets]
    Select --> Verify
    Verify --> Generation[Publish immutable runtime generation]
    Generation --> Stable[Stable guest runtime path]
    Stable --> Services[containerd and dockerd]
    Services --> Workload[Container workload]

The stable path changes as a whole when a new generation is published. Failed or incomplete copies do not become the active runtime, which keeps a previous working generation available until the replacement is complete.

References: guest/…/runtime_materialize.rs• L22-46 guest/…/runtime_materialize.rs• L75-131

Runtime startup

Runtime startup prepares the guest before it starts container services. The agent makes the required kernel and writable filesystem facilities available, materializes the local runtime, starts containerd, and starts dockerd against the guest data store. It reports readiness only after the Docker API answers /_ping.

The startup sequence has distinct service meanings:

  • A reachable containerd socket means containerd can accept connections.
  • A reachable dockerd socket means dockerd has opened its endpoint.
  • A successful Docker /_ping means the engine has completed enough initialization to accept Docker work.

The host asks the agent to ensure this runtime without holding the request open for the full cold-start period. One caller starts the work in the background. Other callers receive an in-progress result, and later calls receive the cached ready or failed result. A failed attempt can be retried by a later ensure request.

References: guest/…/ensure_runtime.rs• L39-50 guest/…/ensure_runtime.rs• L86-101

sequenceDiagram
    participant Host as Host engine
    participant Agent as Guest agent
    participant Runtime as containerd and dockerd
    participant API as Docker API

    Host->>Agent: Ensure runtime
    Agent-->>Host: Starting
    Agent->>Agent: Prepare guest prerequisites
    Agent->>Runtime: Start containerd
    Runtime-->>Agent: containerd socket ready
    Agent->>Runtime: Start dockerd
    Runtime->>API: Open socket and load state
    Agent->>API: Probe /_ping
    API-->>Agent: Ready
    Agent-->>Host: Ready and endpoint
    Host->>Agent: Poll or use Docker endpoint

The host engine starts the System VM first, then waits for the guest container runtime. This ordering makes VM readiness distinct from Docker readiness: a VM process can exist, and the guest agent can answer, while dockerd is still loading its state.

References: app/…/runtime.rs• L861-927 guest/…/runtime.rs• L56-75 guest/…/runtime.rs• L96-137

Workload lifecycle

Container lifecycle requests enter through the Docker-compatible host API and are proxied to dockerd in the System VM. The host adds the work that depends on the container's guest state, such as setting up host port forwarding and DNS after a successful start. Stop, kill, restart, and remove requests update or remove that host-side state after the guest operation succeeds.

flowchart LR
    Request[Docker container request] --> Host[Host Docker layer]
    Host --> Ready[Ensure System VM and runtime readiness]
    Ready --> Proxy[Proxy request to guest dockerd]
    Proxy --> Engine[containerd and dockerd]
    Engine --> Process[Create or control workload process]
    Process --> Inspect[Inspect guest state]
    Inspect --> HostState[Update host DNS and port forwarding]

Container creation carries the workload contract. It includes the image, command, environment, working directory, mounts, resource limits, ports, labels, and restart policy. The Docker-compatible API sends this contract to guest dockerd, which creates and starts the container.

The arcbox-container crate provides a host-side domain model for this contract. It is not the live container manager today. The current execution path is the Docker API proxy, guest dockerd, and containerd.

References: runtime/…/config.rs• L21-54 rpc/…/container.proto• L67-99 runtime/AGENTS.md• L15-25

The host records the canonical full container ID and name after a successful start. Later lifecycle calls can use a name, a short ID, or the full ID while host networking remains keyed by the canonical ID. A periodic reconciler checks the guest's running set so natural exits, OOM kills, auto-removal, and direct guest operations do not leave stale host forwarding or DNS entries.

References: app/…/mod.rs• L78-109 app/…/mod.rs• L288-324 app/…/host_reconciler.rs• L1-11

OCI workload model

The OCI model describes the inputs and state that a low-level container runtime needs. An OCI bundle is a directory with config.json and a root filesystem. The configuration defines the process, root, mounts, Linux isolation settings, and related limits. The bundle layer resolves the root filesystem and validates the bundle before a runtime can use it.

References: runtime/…/bundle.rs• L1-7 runtime/…/bundle.rs• L36-73

The OCI state model records the container ID, bundle path, process ID, annotations, timestamps, root filesystem, and exit code. Its status moves through creating, created, running, and stopped. The state store persists this record by container ID so a runtime can recover the last known lifecycle state.

OCI stateMeaningNext normal state
creatingThe runtime is preparing the bundle and process environment.created
createdThe container exists but its init process has not started.running
runningThe container init process has a guest PID.stopped
stoppedThe process ended and the state carries its exit result.None

Creation can move directly to stopped when setup fails. This gives failure handling a terminal state instead of leaving a partially created workload looking active.

References: runtime/…/state.rs• L15-40 runtime/…/state.rs• L91-105 runtime/…/state.rs• L109-185

Engine lifecycle relationship

Engine-managed lifecycle state describes the System VM and the availability of its guest services. OCI or Docker container state describes an individual workload inside that VM. The engine must therefore establish readiness in layers rather than map one state into the other.

LayerWhat it provesWhat it does not prove
VM process runningThe System VM process exists.The guest agent or Docker engine is ready.
Guest agent readyThe host can exchange control requests with the guest.dockerd has finished loading containers.
Docker runtime readydockerd answers /_ping and can accept Docker work.A specific container is running.
Container runningThe workload process is active in the guest.The System VM will remain available.

The runtime manager uses the System VM lifecycle to start or stop the shared guest. A VM restart stops running containers, but the persistent Docker data image preserves container and image records for the next boot. The Docker proxy uses a restart generation to discard stale connections on the next request, while consumers that need the VM coming up watch the VM lifecycle state itself.

References: app/…/runtime.rs• L518-531 app/…/runtime.rs• L578-593

This separation also explains why a successful VM readiness check is not enough for a container request. The host must wait for the guest runtime's API readiness before it proxies Docker work, and the guest runtime must still report the individual container result after that point. The related guest-agent control path is described in Guest agent integration.

References: app/…/runtime.rs• L460-471 guest/…/runtime.rs• L372-456

Exec workload flow

Exec creates a second process inside an existing running container. The host-side exec model keeps the command, environment, working directory, user, TTY, attach mode, and container ID. With a live agent connection, the manager sends these parameters to the guest and tracks the returned PID, output, and exit code.

The exec path supports attached and detached work. Attached work returns output and a completion result when the guest process ends. Detached work returns after the guest starts the process, and a later exit notification completes the local exec record. TTY resize is valid only while a TTY-backed exec is running.

References: runtime/…/exec.rs• L41-64 runtime/…/exec.rs• L115-163 runtime/…/exec.rs• L221-323

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the three readiness meanings aligned: VM lifecycle readiness, guest runtime readiness, and Docker /_ping readiness. A change to one timeout or probe can make the host accept work too early or report a healthy VM as an unusable runtime.
  • When changing the runtime manifest or asset path, keep manifest generation, digest verification, stable-link publication, architecture selection, and FEX registration aligned. A new generation must not publish until every required executable is verified.
  • When changing Docker container lifecycle handling, keep canonical ID resolution, host port forwarding, DNS registration, immediate teardown, and periodic reconciliation aligned. A new lifecycle result can otherwise leave host state for a stopped guest workload.
  • When mapping container state between Docker and OCI surfaces, preserve their different state vocabularies. Docker-facing state includes paused, restarting, removing, and dead; OCI state has a smaller validated lifecycle.
  • When changing containerd snapshot behavior, keep the guest snapshot lookup and the host filesystem consumer aligned with the containerd namespace, snapshotter, and mount shape.

Important failure modes

TriggerConsequenceGuard
Dockerd socket opens while its API is still loading stateThe host can report readiness and send requests that fail during startupUse Docker /_ping as the ready gate, not socket reachability alone.
Runtime asset digest or generation does not match the manifestThe guest cannot safely publish the requested runtime generationVerify the manifest version and each asset digest before publication.
FEX is missing for a linux/amd64 workloadThe workload cannot execute correctly in the shared guestFail closed during container creation instead of falling back to another VM or translator.
A container exits without a matching host API callPort forwarding, DNS, or name aliases can remain staleReconcile registered host state against the guest's running container IDs.
A guest status query fails during reconciliationLive host networking could be removed by mistakeSkip teardown for that cycle and retry later.
A lifecycle request uses a name or short ID after the container's host state was registered by full IDTeardown can miss the host networking recordResolve the request token to the canonical full container ID before teardown.
A workload setup error leaves OCI state before a terminal transitionThe workload can appear stuck in creationAllow creation failure to transition directly to stopped.

Key files

FileWhy to read it
app/…/runtime.rsShows how the engine starts the System VM, waits for the guest runtime, and distinguishes VM lifecycle state from Docker readiness.
app/…/mod.rsShows the host lifecycle boundary for create, start, stop, kill, restart, and remove operations.
app/…/routing.rsShows the single-VM execution model and the native-versus-FEX workload decision.
app/…/host_reconciler.rsShows the backstop that removes host networking state after unobserved guest exits.
guest/…/runtime.rsShows guest runtime startup, service probes, and Docker API readiness.
guest/…/ensure_runtime.rsShows the non-blocking ensure state machine and cached runtime readiness result.
guest/…/runtime_materialize.rsShows verified, atomic publication of the guest-local runtime generation.
runtime/…/bundle.rsShows the OCI bundle as the configuration and root filesystem input to a runtime.
runtime/…/state.rsShows OCI lifecycle state, persistence, and valid transitions.
runtime/…/exec.rsShows the host-to-guest model for commands run inside an existing container.
rpc/…/container.protoShows the public container lifecycle and exec contract.