150 Commits

Author SHA1 Message Date
Raj b2994ac369 Add container machine for managing persistent Linux VMs (#1662)
## Type of Change
- [ ] Bug fix
- [x] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
`container` runs each workload in an ephemeral VM, so there's no
built-in way to keep a persistent Linux environment you can log into and
work in. `container machine` adds one.

A container machine is a lightweight, persistent, and integrated Linux
environments that feel like an extension of your Mac, created from
standard OCI images with a familiar UX. The login user matches your host
account with passwordless `sudo`, your home directory is mounted inside
the VM, and each machine keeps its filesystem and runs the image's own
init system (such as`systemd` or `openrc`).

```bash
container machine create alpine:3.22 --name my-machine
container machine run -n my-machine # interactive shell
container machine set -n my-machine cpus=4 memory=8G
```

Subcommands: `create`, `run`, `list` (`ls`), `inspect`, `set`,
`set-default`, `logs`, `stop`, `delete` (`rm`); `m` aliases `machine`.
Docs added to `docs/command-reference.md` (Machine Management) and
`docs/how-to.md` ("Use container machines").

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs

Signed-off-by: Raj Aryan Singh <rajaryan_singh@apple.com>
Co-authored-by: Jaewon Hur <jaewon_hur@apple.com>
Co-authored-by: John Logan <john_logan@apple.com>
Co-authored-by: Michael Crosby <michael_crosby@apple.com>
Co-authored-by: Eric Ernst <eric_ernst@apple.com>
Co-authored-by: Danny Canter <danny_canter@apple.com>
2026-06-08 11:38:49 -07:00
AJ Emory 847a004eac Conform containers to ManagedResource (#1656)
- Closes #1651 
- Adds ManagedContainer that conforms to Managed Resource
2026-06-05 17:27:56 -07:00
Saehej Kang 1f4b47061e [images]: fix image load/save to use FilePathOps utility (#1590)
- Relates to apple/containerization#744.
- Use the new `FilePathOps` utility functions.
2026-06-05 09:28:08 -07:00
Raj 822b47b877 Fix --format yaml and toml output (#1653)
- Closes #1528.
- Several commands (`builder status`, `image list`,
  `stats`, `system df`, `system status`) advertised
  `--format yaml` and `--format toml` but only handled
  `json`, and every other format fell through to the
  table. With this PR, we now route them through one
  shared renderer with an exhaustive switch over the
  format enum, so a missing format would now be a
  compile error, and not just fail silently.
- Since TOML has no top level array, TOML output
  now wraps list payloads under an `items` key,
  because otherwise it was returning nothing for lists.
- `stats` now prints one static result for machine
  readable formats instead of opening its live table
  view.
- `builder status` now returns an empty list for
  json/yaml/toml when no builder is running, instead 
  of the unparseable "builder is not running" text.
  The table view keeps the message.
- with `--quiet` and no builder it now exits 0 with
  no output, earlier it exited non-zero.
2026-06-05 08:32:12 -07:00
Kathryn Baldauf 1d0d43668d Rearrange shape of JSON output for images (#1652)
- This PR changes the shape of the JSON
  output for image resources to align closer with
  `VolumeResource` and `NetworkResource`.
  This includes adding `creationDate` in the
  `configuration` section of the image output.
- This PR additionally cleans up some of the logic
  around the `ImageResource` struct construction.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-06-05 08:09:53 -07:00
J Logan 59e015acd1 Use name instead of id in NetworkConfiguration. (#1648)
- Closes #1647.
- `id` will become a system assigned (Docker-like) identifier
  for the managed resource, and `configuration.name` is the
  user-assigned name.
2026-06-04 13:03:29 -07:00
J Logan 89fa98c55a Write log/error output from commands to stderr. (#1632)
- Closes #1631.
- The standard output should only contain result data,
  so that scripts consuming stdout don't need to scrape.
2026-06-03 16:17:59 -07:00
Kathryn Baldauf 94d6d0ac36 Add an error message for dockerfile >= 16KB until #735 is resolved (#1634)
Closes https://github.com/apple/container/issues/1633. We have a known
issue https://github.com/apple/container/issues/735 where Dockerfiles
over the size 16kb will fail to build due to "Transport became inactive"
or "Stream unexpectedly closed" errors. While we wait for a fix for
https://github.com/apple/container/issues/735, this PR adds an error
message if a user tries to build an image using a dockerfile >= 16kb.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-06-03 13:02:27 -07:00
Danny Canter 796630258b kill: Wait for container to exit after sigkill (#1589)
Today when we send a signal we don't wait for the container to exit, as
we don't know what signals the program will actually do anything with.
However, sigkill does not fit this mold, and we should wait for the
container to exit (or be removed for --rm containers).
2026-06-02 14:26:17 -07:00
J Logan e20aca8203 Normalize JSON output for network and volume resources. (#1624)
Normalize JSON output for network and volume resources. (#1624)
- Reworks both JSON output presets to use sorted keys, ISO timestamps.
`compact` is used for `ls` output, and `pretty` is used for `inspect`.
- Extracts non-DRY option configuration into presets.
- Closes #1623.
2026-06-01 21:42:10 -07:00
Kathryn Baldauf 55f1e4fdf4 Create ImageResource conforming to ManagedResource (#1619)
- Closes #1625.
- For now, the ImageResource compliance happens
  at the CLI level. We will work on pushing that into or
  closer to the APIServer at a later time.

## Testing
- [x] Tested locally

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-06-01 17:01:20 -07:00
J Logan 37595a734c Remove XPC compatibility code, simplify network model. (#1616)
- Refactor network model types: replace `NetworkState` enum and
phase-based NetworkStatus with a flat `NetworkStatus` struct.
- Simplify API server ↔ plugin protocol: plugin `status()` returns
runtime status only, API server owns configuration.
- `NetworksService` `list()`/`create()` now return `NetworkResource`
directly.
- Remove lifecycle phase checks and state machine guards throughout CLI
and API server.
- `variant` is plugin-specific, it's not a required property. This PR
replaces `NetworkPluginInfo` with a `plugin` name property on
`NetworkConfiguration` and an `options` list similar to that for
volumes.
- Moved `variant` to the option list.
2026-05-29 12:33:45 -07:00
Kathryn Baldauf 046884df37 Use ManagedResource for volumes in CLI commands (#1607)
## Type of Change
- [x] New feature  

## Motivation and Context
Related to https://github.com/apple/container/issues/1404.

This PR adds the initial work to have volume resources conform to
ManagedResource, in alignment with other resources such as networks (see
[here](https://github.com/apple/container/pull/1421)). Further work is
necessary to move the use of `VolumeResource` down to the APIServer (in
the VolumesService) and in the volume client. Volumes do not currently
have any plugin or runtime state, so that information is not included in
the `VolumeResource`, but could be added later if needed.

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-05-28 09:33:21 -07:00
NONE 685966d026 cli: resolve subcommand path in container help (#1587)
- Fixes #1509. The CLI's own help text tells users to
  run `container help <subcommand>`, but every form
  of that results in an error.
- Added a captured subcommand path, walked 
  Application`'s `subcommands` + `groupedSubcommands`
  tree (matching `commandName` and `aliases`), and
  printed `Application.helpMessage(for:)` for the resolved
  target. Empty path keeps existing plugin-aware top-level
  help; unknown path throws `ValidationError`.
2026-05-27 10:54:49 -07:00
Kathryn Baldauf 25ab5934e4 Support use of custom app root with system config in CLI commands (#1600)
## Type of Change
- [x] Bug fix

## Motivation and Context
Many CLI commands need to reference the system configurations for
`container`. Previously, CLI commands would try to load the system
configurations from the default application root location, regardless of
if `container` had been started with a custom application root location.
This PR fixes that issue by having each CLI command ping the APIServer's
health check service to get the correct app root path.

Closes https://github.com/apple/container/issues/1576

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-05-26 14:33:53 -07:00
J Logan ca3a4d6670 Use FilePath for app, install, and log roots. (#1558)
- Closes #1557.
- Replaces `executableURL` utility function for getting app executable
path with `executablePath`.
- Adds `FilePath.resolvingSymlinks()` extension.
- Also converts for FilePath for types in `ContainerVersion` target.
2026-05-26 13:58:55 -07:00
J Logan 04220b12d0 Adds vertical space between groups in help. (#1585)
- Closes #1513.
2026-05-22 08:56:25 -07:00
Danny Canter de780c1478 cli: Add support for --stop-signal (#1462)
- Closes #1581.
- This adds stop signal support to the cli. The priority is:
  1. If an explicit stop signal is passed on the cli use this.
  2. If not, check if there is a stop signal in the image config.
  3. Finally, use the default (TERM).
2026-05-21 17:55:48 -07:00
jwhur df35f79ae0 Update container copy to use FilePath (#1580)
- Replace `URL` with `FilePath` in `container copy` (#1557).
  In addition, make `copyIn`/`copyOut` API to use `String` for path as we
  need to preserve the trailing slash to the `LinuxContainer.copy`---i.e.,
  this trailing slash is used in `LinuxContainer.copy` to determine copy
  behavior.
2026-05-20 13:50:08 -07:00
Saehej Kang 4f097eb891 [images]: fix image load error to write to stderr and use FilePath (#1570)
- Closes #1535.
- Closes #1573.
2026-05-20 10:46:17 -07:00
Saehej Kang 38075f3275 [images]: convert save to use FilePath (#1574)
- Closes #1573.
2026-05-20 10:43:12 -07:00
Simone Panico 9895ba8d08 Add container copy/cp command for host-container file transfer (#1190)
## Type of Change
- [ ] Bug fix
- [x] New feature  
- [ ] Breaking change
- [x] Documentation update

## Motivation and Context
Adds the `container copy` (aliased as `cp`) command to copy files
between a running container and the local filesystem.

I saw [#1023](https://github.com/apple/container/pull/1023) and the
feedback from @dcantah — the previous attempt relied on tar being
installed inside the container.
This implementation takes the recommended approach:
file transfers go through the guest agent via the existing
`copyIn`/`copyOut` methods on the core `Containerization`, with no
dependency on container tooling.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs

---------

Co-authored-by: jwhur <57657645+JaewonHur@users.noreply.github.com>
2026-05-20 10:03:36 -07:00
Raj bd1916f9b3 Make inspect error handling for missing resources consistent (#1564)
- Closes #1539.
- All `inspect` commands now consistently return
  exit 1 with a clear error when a requested resource
  is missing.
2026-05-16 08:28:37 -07:00
J Logan 5b83b4a9ac Rename config file to config.toml. (#1568)
- Closes #1565.
- `runtime-config.toml` suggested the config
  pertains to just the runtime (managing container
  workloads) aspect of the system.
- Also renames `ADDR` columns to `IP` in 
  `container ls` and `container builder status`.
2026-05-16 08:23:21 -07:00
Raj 061ab83bea Validate container system logs --last flag (#1561)
- Closes #1530.

## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Reject invalid `--last` values in system logs, matching the format
accepted by `log show`.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs
2026-05-15 14:23:28 -07:00
Raj cb4748f589 Reject conflicting volume delete flags (#1560)
- Closes #1531 

## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Reject explicitly supplied volume names when `--all` is passed to volume
delete, matching the behavior of container/image/network delete.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-05-15 14:22:40 -07:00
ChengHao Yang 5317536888 Fix: image list align with other commands when use format should ignore quiet (#1553)
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2026-05-15 01:02:07 -07:00
Raj 16f5fc705f Fix inconsistent volume createdAt JSON encoding (#1556)
- Closes #1533 
- This PR aligns `volume list --format json` date
  encoding with volume inspect by using ISO-8601
  instead of the default numeric reference-date
  format.
2026-05-15 00:59:28 -07:00
Noah Thornton a967399d48 Add support for layered and plugin configurations (#1543)
- This adds support for reading configurations from
  a three layer hierarchy:
  1. User provided TOML
  2. Install root TOML
  3. Code defaults
- We add some code to support plugin configurations
  via the ConfigurationLoader. Each plugin can provide
  a struct with an accompanying id that gets used to
  parse the scoped section of the TOML.
2026-05-12 14:35:21 -07:00
Noah Thornton 0328f5c4c5 Centralize utilities for configuration loading and path parsing (#1448)
This creates a more centralized utility to find and load configuration files, as a follow up to (pr: https://github.com/apple/container/pull/1425).
2026-05-08 12:29:28 -04:00
Noah Thornton e3c49803a0 Move to TOML configuration for defaults (#1425)
- Discussion topic #1336.
- This change migrates away from using `UserDefaults`,
  instead providing a TOML configuration mechanism for
  user configurable settings. All existing system property
  settings keys are supported in the new configuration
  file. However, users will have to migrate any settings
  they have configured in the `UserDefaults` into TOML
  for these settings to take effect.
- Breaking changes:
  * `container system property get` is removed in favor of
    users directly utilizing `container system property list --format toml | jq<>`.
  * `container system property set` is removed since the TOML
    configuration is effectively immutable during the lifetime of the
    `container` daemon. Uses can edit the TOML they have in their home
    directory, however no changes will take effect until the daemon is
    restarted via `container system stop && container system start`
* `container system property list --format table` is removed as
    generating tabular format is non-trivial and the new TOML format is
    intended to be human readable
2026-05-04 12:04:24 -07:00
Danny Canter 8a25213190 Deps: Bump CZ to 0.32.0 (#1498)
Signals changed from being raw ints to a new Signal type.
2026-05-04 11:30:11 -07:00
J Logan b1f3c0d35b Use NetworkResource for network management in API server. (#1421)
- Part of #1404.
- Evolves API to use NetworkResource that conforms to ManagedResource.
- BREAKING CHANGE - compile time impact due to changes to Swift client
API signatures. No change to persistent data or API server XPC
protocols.
2026-04-30 11:06:50 -07:00
J Logan 472cb1950f Build output should just be tags/paths. (#1478)
- Closes #1477.

## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
stdout should contain results that can be piped

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-04-30 10:29:13 -07:00
Mike Drob f9899013fd Merge commit from fork
* Use DNSName for input

* Use pqdn instead of fqdn.

* Update Sources/DNSServer/Records/DNSName.swift

Co-authored-by: J Logan <john_logan@apple.com>

* Simplify description

* Add test

* Make fmt

---------

Co-authored-by: jwhur <jaewon_hur@apple.com>
Co-authored-by: jwhur <57657645+JaewonHur@users.noreply.github.com>
Co-authored-by: J Logan <john_logan@apple.com>
2026-04-30 09:33:26 -05:00
Matt Van Horn bfe587b8e8 ImagePush: print image reference to stdout on success (#1470)
-Resolves #1466.
- `container image push <ref>` previously produced no
  standard output on success. Print the fully qualified
  reference (`image.reference`) after the push completes
  so callers can pipe the output into subsequent
  commands.

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
2026-04-29 19:31:47 -07:00
J Logan 651811cc09 Fix "not installing shadowed plugin" startup log noise. (#1451)
- Closes #1450.
- If we require that bundle-packaged installs must populate a
Unix-structured `bin` and `libexec`, we don't need the code that
searches the app bundle install root. As it stands, we enumerate both
the app bundle and the Linux paths, meaning we're looking at the same
plugins (in different paths) twice.
2026-04-27 11:32:00 -07:00
Raj e96debca8a add plugin label to builder (#1443)
## Type of Change
- [ ] Bug fix
- [x] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
add plugin label to builder

## Testing
- [ ] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-22 14:51:52 -07:00
ChengHao Yang 44754dacaf Add container system version with format yaml (#1353)
Fixed #1156. Introduces yaml formatting.

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2026-04-22 14:26:20 -07:00
J Logan 6a3266fbe7 Make ProgressFlags.makeConfig() public. (#1438)
- Closes #1437.
- Allows use by third-party extensions.
2026-04-22 13:02:17 -07:00
J Logan d15fe22e31 Makes bootstrap env parameter compatible with older clients. (#1434)
- Closes #1433.
- Renames `env` parameter to `dynamicEnv` to differentiate these
special-case environment variables from the standard container
environment.
- Use `[String: String]` instead of `[String: String]?`.
- Default to `[:]` when an down-revision client calls bootstrap without
supplying `dynamicEnv`.
2026-04-20 20:38:33 -07:00
jwhur 2ed65b9a53 Fix using docker specific ignore with read-only build context (#1349)
This PR resolves #1343.
This PR depends on apple/container-builder-shim#72.

Do not create staging directory under build context, but pass
dockerignore file bytes to the container-builder-shim.

## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
[Why is this change needed?]

## Testing
- [x] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-20 11:58:43 -07:00
Novikov Kirill 49079da73e improve error message when image save platform is not available (#1418)
- Closes #874.
- Image save now fails fast with a clear error when the requested
  platform is not available locally.
- The message lists the platforms that ARE available so the user
  knows what they can save.
2026-04-20 10:58:39 -07:00
J Logan 04c597c577 Update builder API to use grpc-swift-2. (#1309) (#1416)
- Closes #1308.
- Applies dependency and code changes similar to
apple/containerization#578.
- Upgrades hawkeye to latest version.
- Update StderrLogHandler not to create a (non-Sendable) Swift time
formatter object for every log message.
2026-04-20 08:39:43 -07:00
jwhur 49f1a5693f Fix ssh forwarding to use current SSH_AUTH_SOCK value (#1420)
This PR fixes #357, passing `SSH_AUTH_SOCK` env variable from current
terminal to the `SandboxService` so that the container can mount the
correct ssh auth socket. For that, it introduces `env` parameters to
`bootstrap` RPC of both `ContainersService` and `SandboxService`. This
parameter is used only for passing `SSH_AUTH_SOCK` now, but can be
extended to pass more runtime env variables.

This PR is a follow up PR of #1214.

## Type of Change
- [X] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Container run `--ssh` was inheriting `SSH_AUTH_SOCK` env variable from
launchd, not from current terminal.

## Testing
- [X] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-17 11:56:16 -07:00
Noah Thornton 9be1020679 Move to TOML configuration for plugin configurations (#1422)
This change migrates plugin config format away from using JSON to use
TOML.
- Addresses the plugin portion of discussion #1336

## Type of Change
- [ ] Bug fix
- [X] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Context within https://github.com/apple/container/discussions/1336

> We're looking to improve the user experience and overall functionality
of setting defaults for container to better enable future use cases.
> 
> Today container uses macOS's
[UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults)
to configure settings needed at runtime. As mentioned in
https://github.com/apple/container/issues/608, UserDefaults may be
idiomatic for macOS, but they apply globally to all sessions and do not
handle representing complex, hierarchical data well. Additionally, we
currently have two ways of setting these defaults, either directly with
macOS's defaults command or through container system property.
> 
> https://github.com/apple/container/issues/608 proposes moving to use
environment variables in place of UserDefaults. However, we do not
believe this is sufficient. Environment variables are not in a
consistent location, are not sourced from data, and also do not handle
representing complex, hierarchical data well.

As part of this migration to TOML for user settings we want to also move
plugin settings to use TOML so that we can have a singular file format
for `container` configurations.


## Testing
- [X] Tested locally
- [X] Added/updated tests
- [ ] Added/updated docs
2026-04-17 10:56:46 -07:00
Novikov Kirill 129c2dc97f Fall back to simple text output when stdout is not a TTY (#1392)
- Detect when stdout is not a tty and fall back to simple
  line-by-line status output.
- Fixes silent commands when piping to a file.
- Closes #113.
2026-04-10 16:29:39 -07:00
Nikunj Thakur 1c37384831 Add Color Progress Output Mode (#1384)
- Adds a color progress output mode (`--progress color`)
  that renders ANSI-colored progress output with visual
  differentiation between progress states.
- Like `ansi` mode, this feature requires a TTY.
- Closes #1366
2026-04-10 09:19:16 -07:00
J Logan a1981c30ac API: Rename to NetworkClient, client as instance. (#1405)
- Part of #1404.
- COMPATIBILITY: Breaking change to client API. XPC protocol and
persistent data remain fully compatibile.
- Renames `ClientNetwork` to `NetworkClient`, aligning with
`ContainerClient`.
- Client uses instance methods instead of utility functions, with an
`init(serviceIdentifier:)` for the XPC service name. The value is
currently unused.
2026-04-08 13:41:12 -07:00
Danny Canter a557ce80a5 Add capabilities support (#1383)
Closes #1352

Containerization has had support for a bit, it was just never brought
over here. It's exposed on the CLI via the classic `--cap-add` and
`--cap-drop` UX.
2026-04-07 17:09:56 -07:00