# What Is the Purpose of the `cmd` Directory in apple/container?

> Discover the real purpose of the cmd directory in apple/container. Find out where command-line functions are located and how to use them effectively.

- Repository: [Apple/container](https://github.com/apple/container)
- Tags: internals
- Published: 2026-06-27

---

**The apple/container repository does not contain a `cmd` directory; command-line functionality is provided by Swift executables defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) and Bash helper scripts located in the `scripts/` folder.**

The `cmd` directory is a conventional pattern in Go projects that typically houses command-line entry points. However, according to the apple/container source code, this repository follows Swift Package Manager conventions instead, distributing CLI functionality across executable targets and shell scripts.

## Why There Is No `cmd` Directory in apple/container

Unlike Go-based container tools that organize binaries under `cmd/`, apple/container uses the Swift Package Manager build system. The repository structure omits the `cmd` directory entirely because Swift executables are defined declaratively in the package manifest rather than requiring a specific directory name.

In this architecture, the **executable target** specified in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) serves the same purpose that `cmd/` would in a Go project—providing the compiled binary entry point—while the actual implementation logic resides in the `Sources/` directory.

## Where Command-Line Functionality Lives

### Swift Package Executable Target

The primary CLI entry point is defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) as an executable target. When you build the project using `swift build`, the compiler generates the binary from Swift source files located in `Sources/ContainerPlugin/` and related modules.

According to the repository structure, the core container plugin system lives in `Sources/ContainerPlugin/`, which the CLI executable depends upon. This module contains the runtime logic that the command-line interface exposes to users.

### Helper Scripts in `scripts/`

For installation and lifecycle management, apple/container provides Bash wrappers in the `scripts/` directory:

- [`install-init.sh`](https://github.com/apple/container/blob/main/install-init.sh) – Installs the container runtime
- [`update-container.sh`](https://github.com/apple/container/blob/main/update-container.sh) – Updates existing installations  
- [`uninstall-container.sh`](https://github.com/apple/container/blob/main/uninstall-container.sh) – Removes the container runtime

These scripts handle environment setup and delegate to the compiled Swift binary, effectively serving as the user-facing command layer that would traditionally reside in `cmd/` in other languages.

## How to Build and Run the Container CLI

Since there is no `cmd` directory to navigate, you interact with the tool through the Swift build system or the provided scripts.

Build the executable from the package root:

```bash
swift build -c release

```

Run the compiled binary directly:

```bash
.build/release/container --help

```

Execute the installation script (which wraps the binary):

```bash
./scripts/install-init.sh

```

Update an existing installation:

```bash
./scripts/update-container.sh

```

Remove the container runtime:

```bash
./scripts/uninstall-container.sh

```

## Key Files Providing CLI Functionality

Understanding the repository layout clarifies where command-line logic resides in the absence of a `cmd` folder:

- **[`Package.swift`](https://github.com/apple/container/blob/main/Package.swift)** – Defines the executable target and its dependencies; serves as the build entry point equivalent to `cmd/` in Go projects.
- **`Sources/ContainerPlugin/`** – Contains the Swift source code for the container plugin system that powers the CLI.
- **[`scripts/install-init.sh`](https://github.com/apple/container/blob/main/scripts/install-init.sh)** – Bash wrapper for initial installation.
- **[`scripts/update-container.sh`](https://github.com/apple/container/blob/main/scripts/update-container.sh)** – Bash wrapper for updates.
- **[`scripts/uninstall-container.sh`](https://github.com/apple/container/blob/main/scripts/uninstall-container.sh)** – Bash wrapper for uninstallation.

## Summary

- The **apple/container** repository does not contain a `cmd` directory.
- Command-line functionality is provided by **Swift executables** defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) and compiled to `.build/release/container`.
- **Bash scripts** in `scripts/` ([`install-init.sh`](https://github.com/apple/container/blob/main/install-init.sh), [`update-container.sh`](https://github.com/apple/container/blob/main/update-container.sh), [`uninstall-container.sh`](https://github.com/apple/container/blob/main/uninstall-container.sh)) handle installation and lifecycle management.
- The **Swift Package Manager** structure replaces the traditional `cmd/` pattern used in Go projects.

## Frequently Asked Questions

### Does apple/container use a `cmd` directory like Go projects?

No. While Go projects commonly use `cmd/` to organize binary entry points, apple/container follows Swift Package Manager conventions. The executable target is defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift), and the source code resides in `Sources/ContainerPlugin/` rather than a `cmd/` directory.

### Where is the main entry point for the container CLI?

The main entry point is defined in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) as an executable target. When compiled with `swift build`, it produces the binary at `.build/release/container`. The source implementation is located in the `Sources/` directory, specifically within modules like `Sources/ContainerPlugin/`.

### How do I install the container tool without a `cmd` directory?

Use the Bash scripts provided in the `scripts/` folder. Run [`./scripts/install-init.sh`](https://github.com/apple/container/blob/main/./scripts/install-init.sh) to install, [`./scripts/update-container.sh`](https://github.com/apple/container/blob/main/./scripts/update-container.sh) to update, or [`./scripts/uninstall-container.sh`](https://github.com/apple/container/blob/main/./scripts/uninstall-container.sh) to remove the tool. These scripts manage the compiled Swift binary and system configuration.

### Why doesn't apple/container follow the standard `cmd/` project structure?

The repository uses Swift, not Go. Swift Package Manager projects define executables in [`Package.swift`](https://github.com/apple/container/blob/main/Package.swift) and place source code in `Sources/`, making the `cmd/` directory pattern unnecessary. This follows Swift language conventions rather than Go's directory-based binary organization.