--- name: apple-container-skill description: Interact with the Apple Container CLI to manage containers, images, volumes, networks, and system services on macOS. Use this skill when the user asks to run, build, or inspect containers or manage the container runtime. --- # Apple Container Skill To use the Apple Container CLI, execute the commands below using the `run_shell_command` tool. **Note:** This CLI is specific to Apple's container implementation. ## Common Workflows & Architecture These patterns represent best practices for using the Apple Container CLI effectively. ### 1. System Lifecycle Management Unlike standard Docker Desktop, the container system services are explicit. * **Startup:** Always verify `container system status` before running operations. If stopped, run `container system start`. * **Kernel:** On first run, `system start` may prompt to install a Linux kernel. The agent should be aware of this initialization step. * **Cleanup:** To save resources when not in use, run `container system stop`. ### 2. Networking & Connectivity * **DNS:** For stable service discovery, configure a local domain: 1. `sudo container system dns create ` (e.g., `test`) 2. `container system property set dns.domain ` 3. Access containers via `http://.`. * **Inter-Container:** Containers are on a `vmnet`. Direct IP communication (`192.168.64.x`) works but can be fragile due to isolation. * **Host Gateway Strategy (Reliable Fallback):** If network plugins are missing or you encounter "No route to host": 1. Publish the service port to the host (e.g., `-p 5432:5432`). 2. Connect from other containers using the **Host Gateway IP** (`192.168.64.1`). 3. *Note:* Disable SSL (`sslmode=disable`) if connection resets occur via the gateway. * **Localhost:** Port forwarding (`-p 8080:80`) works as expected for accessing containers from the host. ### 3. Data Persistence * **Volume Initialization:** New volumes may contain a `lost+found` directory, which can cause "directory not empty" errors. * **Best Practice:** Always configure services (like PostgreSQL) to use a **subdirectory** within the volume. * *Example:* `PGDATA=/var/lib/postgresql/data/pgdata` instead of the root mount point. ### 4. Development Patterns * **Git/SSH:** Use the `--ssh` flag (`container run --ssh ...`) to forward the host's SSH agent. This is the preferred method for cloning private repositories inside containers. * **Hot Reloading:** Use `--volume` (e.g., `-v $(pwd):/app`) to mount source code for immediate feedback, just like standard Docker. * **Builder Tuning:** The build process runs in its own VM. For large builds, explicitly scale the builder: `container builder start --cpus 4 --memory 8g`. ## Critical Setup Before running containers, the system services usually need to be running. * **Check Status:** `container system status` * **Start Services:** `container system start` (may require `sudo` if installing kernel/root components, but usually run as user) ## Commands ### System Management * **`container system start`**: Starts the container services. * Options: `--enable-kernel-install`, `--disable-kernel-install`, `--app-root `, `--install-root `. * **`container system stop`**: Stops the container services. * Options: `--prefix `. * **`container system status`**: Checks if services are running. * **`container system version`**: Shows CLI and API server versions. * **`container system logs`**: Displays system logs. * Options: `--follow`, `--last