Skip to content

Add container-compose: docker-compose compatibility layer#1736

Open
demostenex wants to merge 2 commits into
apple:mainfrom
demostenex:feature/container-compose
Open

Add container-compose: docker-compose compatibility layer#1736
demostenex wants to merge 2 commits into
apple:mainfrom
demostenex:feature/container-compose

Conversation

@demostenex

Copy link
Copy Markdown

Type of Change

  • New feature
  • Documentation update

Motivation and Context

Users migrating from Docker commonly describe their applications in docker-compose.yml files. The container CLI operates on individual containers and has no equivalent of docker compose up. This PR fills that gap with a lightweight Python script (container-compose) that reads a standard compose file and translates each subcommand into the equivalent container invocations.

No changes are made to the container binary or any Swift sources — this is entirely additive, living in examples/ and docs/.

What's included

examples/compose-example/container-compose — the script itself (~800 lines of Python 3, single dependency: PyYAML). Supported subcommands: up, down, ps, logs, exec, build, pull, start, stop, restart, rm, run, config.

Key behaviours:

  • Services start in depends_on topological order (list and condition-dict form)
  • Networks and named volumes are created automatically and prefixed with the project name
  • Every container is labelled with com.container-compose.project and com.container-compose.service for scoped ps / down
  • Project name defaults to the current directory, overridable via -p or COMPOSE_PROJECT_NAME

examples/compose-example/docker-compose.yml — three-service example (nginx + Node.js API + Redis) exercising ports, volumes, networks, resource limits, build definitions and depends_on.

examples/compose-example/README.md — step-by-step walkthrough: install, up, ps, logs, exec, run, build, down.

docs/container-compose.md — reference page covering supported compose keys, project isolation, and known limitations.

Known limitations (documented)

Feature Status
Multiple networks per service Only the first network is attached (container has no network connect)
extra_hosts: host-gateway Docker-specific alias, skipped with a warning
restart policies Not yet supported by container run
healthcheck Not surfaced on container inspect output

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Unit tests (examples/compose-example/test_container_compose.py) — 61 tests covering all pure functions: _parse_json_lines, _as_list, _label_value, service_container_name, project_name, ordered_services, and build_run_args (image, labels, env, ports, volumes, networks, resources, entrypoint, command, caps, workdir, user, flags).

Run with:

cd examples/compose-example
pip3 install pyyaml --break-system-packages
python3 -m unittest discover -v

🤖 Generated with Claude Code

@demostenex demostenex force-pushed the feature/container-compose branch from a68d59c to 92270ef Compare June 15, 2026 19:18
demostenex and others added 2 commits June 15, 2026 16:22
Introduces a Python script and supporting materials that allow users to
bring up multi-container applications described in a standard
docker-compose.yml using Apple's container CLI, without rewriting their
existing compose files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@demostenex demostenex force-pushed the feature/container-compose branch from 92270ef to e835855 Compare June 15, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant