Skip to content

Add container clean (reclaim disk space) for container 1.4.1 - #15

Merged
kylemclaren merged 1 commit into
mainfrom
feat/container-clean
Sep 13, 2026
Merged

kylemclaren merged 1 commit into
mainfrom
feat/container-clean

Conversation

@kylemclaren

@kylemclaren kylemclaren commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Apple container 1.4.1 added container clean, a one-shot trim of freed blocks on a running container's root filesystem and named volume mounts so the host reclaims space from the sparse rootfs.ext4 / volume.img files (apple/container#1949, #2228). Nothing is deleted, and the CLI skips read-only roots and ro mounts.

This wires it into the app:

  • Service: ContainerService.clean(ids:) / cleanArguments(ids:).
  • Containers screen: "Clean" in the row's context and ellipsis menus (running containers only) and a "Clean" pill in the inspector header next to Console. The row's busy spinner and the error banner give feedback.
  • ⌘K palette: "Clean " for each running container, routed through the Containers screen rather than run globally so failures are visible.
  • System screen: "Clean running containers" in the Reclaim space row, with a confirmation explaining what it does. Disabled when nothing is running.
  • Older CLIs: a pre-1.4.1 container rejects the unknown subcommand with a usage error; the UI shows "Cleaning containers requires Apple container 1.4.1 or later" instead of the parser text.
  • README feature table updated.

Test plan

  • xcodebuild build (app target) succeeds
  • xcodebuild test: 144 tests in 19 suites pass, including new containerClean, cleanSendsIDsAndReturnsCleanedList, and cleanOnOlderCLIExplainsVersionRequirement
  • Live check against container 1.4.1 with a throwaway alpine:3.21 container:
    • running container: prints the id, exit 0
    • one valid + one bogus id: cleans the valid one, prints one notFound error line, exit 1 (so the bulk System-screen action reports partial failures as an error, with the failing id named)
    • duplicate ids: deduplicated by the CLI, exit 0
    • missing/stopped container: internalError: "failed to clean container" (cause: "notFound: …"), which the existing classifier maps to .notFound

`container clean` (new in 1.4.1) trims freed blocks on a running
container's root filesystem and named volume mounts so the host can
reclaim the space from the sparse rootfs.ext4 / volume.img files.
Nothing is deleted; the CLI skips read-only roots and `ro` mounts.

- ContainerService.clean(ids:) + cleanArguments(ids:) wrap the command.
- Clean is offered wherever a running container has actions: the row's
  context/ellipsis menu, the inspector header, the ⌘K palette (routed
  through the Containers screen so the busy marker and error banner give
  feedback), and a "Clean running containers" button with confirmation
  in the System screen's Reclaim space row.
- CLIs older than 1.4.1 reject the unknown subcommand with a usage error;
  that is surfaced as "requires Apple container 1.4.1 or later" instead
  of the raw parser text.
- Tests cover argv, output parsing, and the version-requirement mapping.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLMTFj27fkhmYuisPRZaVr
@kylemclaren
kylemclaren merged commit ffbd809 into main Sep 13, 2026
1 check passed
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