Containerization
lastmod 2025-06-10created 2025-06-101 edits
A Swift package for running Linux containers on macOS
About
- Containerization is a Swift-based open-source tool that lets you run Linux containers on macOS
- Works on Apple Silicon Macs, using Virtualization.framework to run each container in isolation inside a lightweight virtual machine
- Includes a range of features such as OCI image management, remote registry integration, ext4 file system creation, and container environment control
- Can support running x86_64 processes on Apple Silicon using Rosetta 2
- Improves developer flexibility and performance with ultra-fast boot, a lightweight environment, kernel version customization, and more
Project overview
- Containerization is a Swift package that helps applications use Linux containers
- Implemented in Swift, it runs on Apple Silicon Macs using Virtualization.framework
- Provides the following features through its API
- OCI image management
- Remote container registry integration
- Creating and populating ext4 file systems
- Interacting with the Netlink socket family
- An optimized Linux kernel for fast boot
- Creating and managing lightweight virtual machines
- Controlling the runtime environment of virtual machines
- Spawning and controlling containerized processes
- Running x86_64 processes on Apple Silicon using Rosetta 2
Design and architecture
- Each Linux container runs inside its own virtual machine
- A dedicated IP address can be assigned per container, making network management simple without port forwarding
- Optimized kernel configuration and a lightweight root file system enable sub-second container boot
- vminitd is a subproject of Containerization, a lightweight init system that runs as the initial process inside the virtual machine
- Configures the runtime environment through a GRPC API and supports managing container process operations
- Relays I/O, signals, and events to the calling process
Requirements
- Requires an Apple Silicon Mac
- Building the package requires
- macOS 15 or later and Xcode 26 Beta
- or macOS 26 Beta 1 or later
- Non-isolated container networking: containers on the same vmnet network cannot communicate with each other
Usage examples
- Provides the cctl executable: a playground for trying out the various features of the API
- Example commands
- Manipulating OCI images
- Logging in to container registries
- Creating root file system blocks
- Running simple Linux containers
- Example commands
Linux kernel configuration
- A Linux kernel is required to run lightweight virtual machines for containers
- The optimized kernel configuration provided by Containerization is located in the kernel directory
- This configuration includes only minimal features, providing fast boot and a lightweight environment
- An API is available for specifying different kernel configurations and versions per container as needed
- Allows testing various kernel versions and configurations
- However, the VIRTIO drivers must be compiled into the kernel (compiled-in)
Development and testing process summary
- Requires preparing an environment with Swift, the Static Linux SDK, and so on
- Source code can be built and tested (make all, make test integration commands, etc.)
- A kernel image is required to run integration tests
Open-source contributions and project status
- Contributions welcome
- Version 0.1.0 is the first official release, and source stability is guaranteed only within a minor version
- The policy may change in future minor releases
Summary
- Containerization is an innovative Swift package that lets developers manage, run, and develop Linux containers on macOS in an optimized environment
- Running each container in its own lightweight virtual machine provides advantages in isolation, performance, networking, and kernel customization
- A suitable solution for developers who want to extend open-source container environments into a native macOS experience