apple /containerization
Containerization is a Swift package for running Linux containers on macOS.
★ 9,019⑂ 409👁 38⑃ 814● 188▤ 3
+2
日增长
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
#226[Request]: FreeBSD container support17 comments · 2025-07-23#74USB support via USB/IP14 comments · 2025-06-10#116[Request]: realizing reuse of ext4 layers with overlaybd (a union block device)10 comments · 2025-06-13#551[Request]: expose seccomp in the API6 comments · 2026-02-23#89Enable Rosetta AOT caching (requires FB14580944 to be fixed)5 comments · 2025-06-11#846[Bug]: Cannot build containerization from scratch on a machine that is behind a network proxy4 comments · 2026-08-19#202[Bug]: Importing ContainerizationOCI breaks SwiftUI's @State4 comments · 2025-07-08#101Explore alternatives to dispatch for stdio4 comments · 2025-06-11