Add container info command#1769
Conversation
Implements issue apple#815: a top-level `container info` command (like `docker info`) that reports system-wide information so tools can use `container` as a drop-in via `ln -s container docker`. The command gathers, from real APIs only: - CLI version/build/commit (ReleaseVersion) - Host architecture, OS, CPU count (Arch / ProcessInfo) - API server status/version/build/commit and app/install/log roots (ClientHealthCheck) - Container counts (total/running) and image count when the daemon is up (ContainerClient.list / ClientImage.list) - Default registry domain, kernel binary path, container CPU/memory, builder image, init image, and DNS domain (ContainerSystemConfig) Supports the standard `--format table|json|yaml|toml` output flag used by other commands. Daemon-dependent sections are omitted gracefully when the API server is not running. Fixes apple#815
|
Nice addition, this looks like a useful I spotted one small bug in the image count path. In That means I think this can be fixed with: It may also be worth adding a small regression test around this path, either by making the gather dependencies injectable or by testing a focused helper, so the image count behavior is covered directly. |
The image count was assigned to a shadowed copy of the resource counts created by an `if var resources` binding, so it never reached the `InfoPayload` returned by `gather()`. As a result `images.total` was omitted from table and JSON output even when `ClientImage.list()` succeeded. Apply the count to the outer value via a small, pure `withImageCount` helper and add regression tests covering the count path.
|
@muk2 Are you going to add the |
|
@muk2 Thanks for the submission. I don't think I had seen the underlying issue before. We're not trying to do 100% compatibility with peripheral docker commands, and with the exception of The closest equivalent in |
|
@jglogan... That makes sense to me. From the outside, the reusable part of this PR seems to be the richer system/status payload rather than the Docker-compatible top-level command name. Moving the useful fields under More broadly, is Apple expecting downstream plug-in/tool developers to build against these Apple-native |
|
@stephenlclarke First, thanks for having a look at the PR and commenting on it! Yes, it'd take a bit of searching but we've had several discussions on Docker CLI compatibility. Long story short, it's not an objective for this project, partly due to the UX goals when we were planning the initial release of the tool, partly due to winding up with We recognize that achieving CLI compatibility eventually in some way is really important. My preference is to do so by being able to use the Docker CLI itself with container. Even if we made Regarding |
|
@jglogan That also helps with the direction I should take in If that matches your intent, I can use that as the organising principle for future small PRs. |
|
@muk2 Thanks for the update - it looks like you created a separate Or could the information you're adding be cleanly integrated into |
Yes. That's pretty much exactly it. You can shell out to the An example of enhancements that would help a future API bridge: evolving the resource model so With regard to Docker CLI compatibility, you can see that we stay very close to how Docker works for the things people use most and where it's a clean fit to do so. The option set for |
Drop the separate top-level `container info` command and fold its richer payload (client, host, resource counts, and system defaults) into `container system status`. `system status` keeps its existing role and exit-code contract: it still reports `unregistered`/`not running` and exits non-zero in those cases, but when the daemon is up it now emits the full client/host/server/paths/resources/defaults view in table or JSON. This avoids a Docker-shaped command name and gives downstream tooling a single Apple-native machine-readable surface, per PR review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@jglogan Good call — there's no real need for a separate command here. I've removed the top-level
The image-count fix from the earlier review carried over, and the unit tests moved to |
|
@muk2 can you update the title and description for the PR, and in the description can you include examples of the new table and json format output. I've kicked off the PRB. Thanks for merging this into the |
|
Seeing some errors in the tests: |
|
@muk2 One other thing that we should fix while we're here! I had noticed this some time back - this shouldn't contain a composition of all the other fields - I think we should just report |
Update TestCLIStatus to the nested `system status` payload (paths.*/server.*) so it decodes the running and not-running cases, fixing the `appRoot` keyNotFound failures and the `apiserver.version`/`apiserver.commit` table assertions. Report the bare release version for `apiServerVersion` in the health check reply instead of the composed `singleLine` string, so `server.version` (and `system version`) show e.g. `1.0.0-23-g7b94575` rather than a composition of the build/commit fields that are already reported separately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@jglogan Thanks — both are addressed in 3f46827. Failing tests:
Verified locally: |
…fo-command # Conflicts: # Tests/CLITests/Subcommands/System/TestCLIStatus.swift
container compose top now renders Docker Compose-style per-container process tables for selected services with UID, PID, PPID, C, STIME, TTY, TIME, and CMD columns. The compose layer uses the generic ContainerClient.processes(id:) API and keeps the PID-only fallback for older or mixed matched-runtime lanes. Live runtime parity now configures CONTAINER_COMPOSE_INIT_IMAGE, installs a matching source-built vminit image through CONTAINER_INIT_IMAGE_NAME, and pins the release stack to the matching stephenlclarke/container and stephenlclarke/containerization commits. Docs, STATUS.md, help support metadata, unit tests, runtime smoke tests, Docker Compose parity coverage, and Apple handoff templates are current for this slice. References: Docker Compose top docs; apple/container#1769; stephenlclarke/container@d03f81b; stephenlclarke/containerization@d8b9585. Release-Highlight: container compose top now supports Docker Compose-style process tables for selected services, including UID, PID, PPID, C, STIME, TTY, TIME, and CMD columns. Release-Highlight: Live Docker Compose parity tests now use a matched source-built vminit image so runtime-backed compose features exercise the same guest service as the host API.
Summary
Adds a top-level
container infocommand — the analog ofdocker info— thatprints client, host, server, storage paths, resource counts, and default
settings in a table or as JSON (
--format json). Daemon-sourced fields populateonly when the API server responds, so the command degrades gracefully to a
"server not running" view when the daemon is stopped.
Testing
make checkpasses (formatting + license headers).SystemInfoTests(5 tests) cover table rendering with and withouta running server, JSON round-tripping, and omission of optional fields. All pass.
container infowith the daemon stopped shows client/host plusserver: not running; aftercontainer system start, server/paths/countspopulate;
container info --format json | jqemits valid JSON.Fixes #815