用途:在 Apple 芯片 macOS 上把 Apple 的 container CLI 当作原生 Linux 容器运行时使用,并指导代理的运行形态选择,而非只提供命令语法。
主要能力:支持一次性容器运行、项目开发 shell、镜像构建与运行、镜像仓库、命名卷、端口发布、主机访问、Unix socket 挂载与发布,以及面向长期 Linux 工作区的 container machine(持久根磁盘、SSH agent 转发、把 macOS 家目录映射到 /Users/<user>)。
使用方式:先做环境检查 sw_vers、uname -m、command -v container、container --version、container system status;要求 Apple 芯片(arm64),当前文档建议 macOS 26+,macOS 15 网络受限。CLI 缺失时优先用 GitHub releases 的 Apple 签名安装包。服务停止时用 container system start。冒烟测试:container run --rm docker.io/library/alpine:latest sh -lc 'uname -a; nslookup github.com'。环境不明时运行 bash skills/apple-container-skill/scripts/diagnose.sh。常见项目 shell:container run --rm -it -v "$PWD:/work" -w /work docker.io/library/ubuntu:24.04 bash。构建运行:container build -t local/app:dev . 与 container run --rm -p 8080:8080 local/app:dev。machine 示例:container machine create local/alpine-machine:latest --name dev --set-default --cpus 4 --memory 8G。脚本化 machine 命令建议用 -- 终止选项,避免 -i 吞掉 stdin。
限制与注意:machine 需要可启动的 init 系统,普通 alpine/ubuntu/debian 应用镜像可能能创建但无法执行命令,需派生 OpenRC 或 systemd 镜像。1.0 起移除 container system property get/set/clear,改用 ~/.config/container/config.toml。1.2.0 未暴露 container run --stop-signal。用户自定义网络需 macOS 26+。容器到主机需用 container system dns create 配置 localhost 域,可能影响 Private Relay。sudo、全局 prune、删除非本任务资源、修改 ~/.ssh/config、扩大绑定挂载、削弱安全控制的 kernel 参数等操作前须询问。首次 machine 命令可能需真实终端完成用户初始化。其余细节见 references/workflows.md、references/troubleshooting.md、references/commands.md。