apple /containerization

Containerization is a Swift package for running Linux containers on macOS.

★ 9,019⑂ 409👁 38⑃ 814● 188▤ 3
SwiftApache-2.0Created 2025-05-29apple.github.io/containerization/documentation/
Download: 0.33.3-prerelease0.33.3-prerelease ↓0.33.32026-06-01
+2
Daily
9,019
stars
409
forks
38
watchers
814
prs
188
issues
3
releases

README

 Containerization


The Containerization package allows applications to use Linux containers.
Containerization is written in Swift and uses Virtualization.framework on Apple silicon.

 Looking for command line binaries for running containers?\
 They are available in the dedicated apple/container repository.

Containerization provides APIs to:

- Manage OCI images.
- Interact with remote registries.
- Create and populate ext4 file systems.
- Interact with the Netlink socket family.
- Create an optimized Linux kernel for fast boot times.
- Spawn lightweight virtual machines and manage the runtime environment.
- Spawn and interact with containerized processes.
- Use Rosetta 2 for running linux/amd64 containers on Apple silicon.

Please view the API documentation for information on the Swift packages that Containerization provides.

 Design

Containerization executes each Linux container inside of its own lightweight virtual machine. Clients can create dedicated IP addresses for every container to remove the need for individual port forwarding. Containers achieve sub-second start times using an optimized Linux kernel configuration and a minimal root filesystem with a lightweight init system.

vminitd is a small init system, which is a subproject within Containerization.
vminitd is spawned as the initial process inside of the virtual machine and provides a GRPC API over vsock.
The API allows the runtime environment to be configured and containerized processes to be launched.
vminitd provides I/O, signals, and events to the calling process when a process is run.

 Backends

Containerization abstracts the VMM behind the VirtualMachineManager /
VirtualMachineInstance protocols and ships two implementations:

- macOS — Virtualization.framework (VZVirtualMachineManager). The shipping path on Apple silicon. Uses Apple's Virtualization framework directly; no extra binaries required.
- Linux — cloud-hypervisor + KVM (CHVirtualMachineManager). One cloud-hypervisor subprocess per VM, controlled over its REST-on-UDS API by the standalone CloudHypervisor Swift package. Block storage uses virtio-blk, shared directories use virtio-fs (one virtiofsd per share), networking uses TAP, and the guest agent is reached over cloud-hypervisor's hybrid vsock — same vminitd contract as the macOS path, so guest-side semantics are unchanged.

The Linux backend requires:

- cloud-hypervisor and virtiofsd on the host. Both are looked up on PATH by default; CHVirtualMachineManager.init accepts explicit URLs to override. virtiofsd is resolved lazily — a VM that uses only block-device mounts can run without it installed at all. Recent stable releases of each are recommended (smoke testing pins specific versions).
- KVM access (/dev/kvm readable + writable by the calling user).
- Pre-staged TAP / bridge / NAT plumbing if the container needs networking. TAPInterface consumes an existing TAP device by name; bringing it up, attaching it to a bridge, and configuring NAT or routing is

Top issues

Latest release

0.33.3-prerelease 0.33.3 Pre-release 2026-06-01

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON