# Where to Find Apple Container Tool Source Code on GitHub

> Find Apple container tool source code on GitHub at apple/container. Explore the Swift Package Manager project and CLI entry point to understand its implementation.

- Repository: [Apple/container](https://github.com/apple/container)
- Tags: getting-started
- Published: 2026-07-03

---

**The Apple container tool source code is publicly available at `github.com/apple/container`, with the Swift Package Manager project organized under the `Sources/` directory and the CLI entry point located in [`Sources/CLI/ContainerCLI.swift`](https://github.com/apple/container/blob/main/Sources/CLI/ContainerCLI.swift).**

The **Apple container tool** is an open-source Swift project maintained by Apple that provides a lightweight container runtime for macOS. If you are looking for the complete source code for Apple's container tool, you will find it hosted on GitHub under the Apple organization. The repository contains everything needed to build the command-line interface, runtime services, and supporting libraries according to the Swift Package Manager structure defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift).

## GitHub Repository Location

All source code for the Apple container tool resides in the official GitHub repository:

`https://github.com/apple/container`

This repository contains the complete Swift Package Manager project. The **[`Package.swift`](https://github.com/apple/container/blob/main/Package.swift)** manifest defines modular libraries including `ContainerCommands`, `ContainerBuild`, `ContainerAPIClient`, and `ContainerRuntimeLinuxServer`, each implementing distinct functional layers of the container system.

## Source Code Architecture

The project follows a modular architecture with all implementation files stored under the `Sources/` directory. Each library lives in its own folder, separating concerns between the command-line interface, runtime, and auxiliary services.

### CLI Entry Point

The entry point for the `container` binary is the **`ContainerCLI`** struct defined in [`Sources/CLI/ContainerCLI.swift`](https://github.com/apple/container/blob/main/Sources/CLI/ContainerCLI.swift). This file carries the `@main` attribute, which invokes `Application.main()` to parse sub-commands, validate configuration, and dispatch execution to the appropriate service handlers.

### Command Implementations

High-level sub-commands such as `run`, `build`, and `push` are implemented in the **`ContainerCommands`** library. For example:

- **[`Sources/ContainerCommands/System/Start.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/System/Start.swift)** handles the `system start` sub-command.
- **[`Sources/ContainerCommands/Build/BuildCommand.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/Build/BuildCommand.swift)** implements the `build` command.
- **[`Sources/ContainerCommands/Run/RunCommand.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/Run/RunCommand.swift)** contains the `run` command logic.

### Linux Runtime Service

The low-level Linux VM runtime used on Apple silicon is provided by the **`ContainerRuntimeLinuxServer`** library. The core runtime logic that launches lightweight VMs is implemented in [`Sources/Services/RuntimeLinux/Server/RuntimeService.swift`](https://github.com/apple/container/blob/main/Sources/Services/RuntimeLinux/Server/RuntimeService.swift).

### Supporting Services

Additional libraries under `Sources/` handle specific concerns:

- **`Sources/Services/Network/`** - Manages port forwarding, VMnet networking, and DNS services.
- **`Sources/ContainerPersistence/`** - Reads and writes configuration files such as [`container.toml`](https://github.com/apple/container/blob/main/container.toml), with the loader implemented in [`ConfigurationLoader.swift`](https://github.com/apple/container/blob/main/ConfigurationLoader.swift).
- **`Sources/ContainerXPC/`** - Provides inter-process communication between the daemon and client processes.
- **`Sources/ContainerLog/`** - Implements unified logging using OSLog, file, and stderr outputs.
- **`Sources/ContainerVersion/`** - Embeds build-time version information into the binary.
- **[`Sources/ContainerBuild/Builder.swift`](https://github.com/apple/container/blob/main/Sources/ContainerBuild/Builder.swift)** - Orchestrates the image build pipeline.

## Building and Running from Source

After cloning the repository, you can build the `container` binary using Swift Package Manager. The following commands demonstrate how the source code maps to CLI functionality:

### Start the System Daemon

```bash
container system start

```

This command invokes the implementation in [`Sources/ContainerCommands/System/Start.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/System/Start.swift), which initializes the background daemon that manages containers.

### Build a Container Image

```bash
container build -t myimage:latest .

```

The `build` command is defined in [`Sources/ContainerCommands/Build/BuildCommand.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/Build/BuildCommand.swift) and calls the `ContainerBuild` library, specifically [`Sources/ContainerBuild/Builder.swift`](https://github.com/apple/container/blob/main/Sources/ContainerBuild/Builder.swift), to orchestrate the build pipeline.

### Run a Container

```bash
container run -p 8080:80 myimage:latest

```

This sub-command is implemented in [`Sources/ContainerCommands/Run/RunCommand.swift`](https://github.com/apple/container/blob/main/Sources/ContainerCommands/Run/RunCommand.swift) and ultimately invokes `ContainerRuntimeLinuxServer` to launch a lightweight VM via [`RuntimeService.swift`](https://github.com/apple/container/blob/main/RuntimeService.swift).

### Using the Swift API Client

You can interact with the container service programmatically using the `ContainerAPIClient` library:

```swift
import ContainerAPIClient

let client = try ContainerAPIClient()
let containers = try await client.list()
print("Running containers:", containers)

```

The Swift client API is declared in [`Sources/Services/ContainerAPIService/Client/ContainerAPIClient.swift`](https://github.com/apple/container/blob/main/Sources/Services/ContainerAPIService/Client/ContainerAPIClient.swift).

## Documentation and Technical References

Beyond the source code, the repository includes comprehensive documentation:

- **[`README.md`](https://github.com/apple/container/blob/main/README.md)** - High-level project introduction, installation steps, and basic usage.
- **[`docs/technical-overview.md`](https://github.com/apple/container/blob/main/docs/technical-overview.md)** - Architectural overview explaining how the container system components interact.
- **[`docs/command-reference.md`](https://github.com/apple/container/blob/main/docs/command-reference.md)** - Complete reference for all CLI commands and available flags.
- **[`BUILDING.md`](https://github.com/apple/container/blob/main/BUILDING.md)** - Instructions for compiling the project from source.

## Summary

- The **Apple container tool source code** is hosted at `github.com/apple/container` as an open-source Swift project.
- The **entry point** is [`Sources/CLI/ContainerCLI.swift`](https://github.com/apple/container/blob/main/Sources/CLI/ContainerCLI.swift), which uses the `@main` attribute to launch the application.
- Source files are organized under `Sources/` into libraries including `ContainerCommands`, `ContainerBuild`, `ContainerRuntimeLinuxServer`, and `ContainerPersistence`.
- Key implementation files include [`RuntimeService.swift`](https://github.com/apple/container/blob/main/RuntimeService.swift) for Linux VM management and [`Builder.swift`](https://github.com/apple/container/blob/main/Builder.swift) for image construction.
- Documentation is available in [`docs/technical-overview.md`](https://github.com/apple/container/blob/main/docs/technical-overview.md) and [`docs/command-reference.md`](https://github.com/apple/container/blob/main/docs/command-reference.md).

## Frequently Asked Questions

### Is Apple's container tool open source?

Yes, Apple's container tool is fully open source and available under the Apple organization on GitHub. The repository includes the complete Swift source code, build instructions, and documentation, allowing developers to inspect, build, and modify the tool.

### What programming language is the Apple container tool written in?

The entire codebase is written in **Swift**. The project uses Swift Package Manager for dependency management and building, with the CLI entry point utilizing Swift's `@main` attribute and async/await patterns for concurrency.

### Where is the entry point for the container command located?

The entry point is defined in **[`Sources/CLI/ContainerCLI.swift`](https://github.com/apple/container/blob/main/Sources/CLI/ContainerCLI.swift)**. This file contains the `ContainerCLI` struct marked with `@main`, which calls `Application.main()` to parse command-line arguments and dispatch to the appropriate sub-command handlers in the `ContainerCommands` library.

### How do I build the container tool from source?

Clone the repository from `github.com/apple/container` and use Swift Package Manager to build the project. The [`BUILDING.md`](https://github.com/apple/container/blob/main/BUILDING.md) file in the repository root provides specific instructions for compiling the binary and installing dependencies. Once built, the `container` binary can be invoked directly from the command line.