Skip to content

Add container info command#1769

Open
muk2 wants to merge 2 commits into
apple:mainfrom
muk2:feat/815-container-info-command
Open

Add container info command#1769
muk2 wants to merge 2 commits into
apple:mainfrom
muk2:feat/815-container-info-command

Conversation

@muk2

@muk2 muk2 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Adds a top-level container info command — the analog of docker info — that
prints client, host, server, storage paths, resource counts, and default
settings in a table or as JSON (--format json). Daemon-sourced fields populate
only when the API server responds, so the command degrades gracefully to a
"server not running" view when the daemon is stopped.

Testing

  • make check passes (formatting + license headers).
  • Unit tests: SystemInfoTests (5 tests) cover table rendering with and without
    a running server, JSON round-tripping, and omission of optional fields. All pass.
  • Manual: container info with the daemon stopped shows client/host plus
    server: not running; after container system start, server/paths/counts
    populate; container info --format json | jq emits valid JSON.

Fixes #815

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
@stephenlclarke

Copy link
Copy Markdown

Nice addition, this looks like a useful docker info-style surface.

I spotted one small bug in the image count path. In SystemInfo.gather(), this block unwraps resources into a local shadow copy:

if var resources, let images = try? await ClientImage.list() {
    resources.images = images.count
}

That means resources.images is updated only on the copy. The InfoPayload returned from gather() still has images == nil, so images.total is omitted from table/JSON output even when ClientImage.list() succeeds.

I think this can be fixed with:

if let images = try? await ClientImage.list() {
    resources?.images = images.count
}

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.
@stephenlclarke

Copy link
Copy Markdown

@muk2 Are you going to add the info command to the docs/command-reference.md

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.

[Request]: The container info command

2 participants