Commit Graph

403 Commits

Author SHA1 Message Date
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
Raj 7358102c68 Fix system df to count content blobs and deduplicate shared storage (#1555)
- Closes #1526 and #1527.

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

## Motivation and Context
This PR fixes `system df` to report actual on-disk allocated bytes
(content blobs + snapshots) instead of summing per-image snapshot sizes.
Orphaned blobs are now included as reclaimable, and storage shared
across tags is no longer double counted. Also consolidates three
identical `calculateDirectorySize` implementations into a shared
`FileManager.allocatedSize(of:)` extension.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-06-01 15:44:43 -07:00
Chris George da8daf31de Use FilePath for PublishSocket (#1594)
- Closes #1593.
2026-06-01 13:35:58 -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
J Logan c5a8d7a802 Reorganize Swift package targets for network plugin. (#1615)
- Part of #1404.
- Updates containerization to 0.33.2.
- Reorganizes network plugin targets into:
  - `ContainerNetworkClient` - network plugin client and default types
- `ContainerNetworkServer` - separate protocols for `Network` which
manages the underlying virtual network, `NetworkService`, which takes a
network and implements the API, and an actor `NetworkHarness` that
marshals between the API and the XPC protocol. The service-harness
separation will help us ensure XPC protocol compatibility in both
directions as we evolve the plugin APIs.
- Removes `disableAllocator()` which is no longer used since #1545
switched over to using XPC connections between runtime and network
plugin instances to track whether a network has attached containers.
2026-05-28 15:26:31 -07:00
J Logan 445c90f927 Fix potential integer math crash on PublishPort. (#1612)
- Closes #1610.
- Discovered, and originally filed as a security advisory, by:
PresidentL <131139636+liyander@users.noreply.github.com>.
- `PublishPort` currently can store invalid combinations of starting
port and range that can overflow UInt16 values when summed, crashing the
process.
- Updates `PublishPort` to validate inputs on initialization.
2026-05-28 11:12:04 -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
J Logan d43b58ec73 Align JSON output with shape for container resource. (#1611)
- Part of #1404.
- Use `configuration` for configuration properties, `state` for current
state label, `status` for status properties.
2026-05-28 09:07:01 -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 8261a27ed0 Add shmSize to management flag's init (#1603)
## Type of Change
- [x] Bug fix

## Motivation and Context
Ensure all fields are initialized in the management flags' init
function. Without this change, if someone calls init() on this set of
flags, they will get an error like

```
Can't read a value from a parsable argument definition.

This error indicates that a property declared with an `@Argument`,
`@Option`, `@Flag`, or `@OptionGroup` property wrapper was neither
initialized to a value nor decoded from command-line arguments.

To get a valid value, either call one of the static parsing methods
(`parse`, `parseAsRoot`, or `main`) or define an initializer that
initializes _every_ property of your parsable type.
```

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-05-26 17:51:10 -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 caff1e9b42 Improve readability of progress bar width computation. (#1584)
- Refines bugfix from #1547, no functional changes.
2026-05-22 13:03:09 -07:00
J Logan 04220b12d0 Adds vertical space between groups in help. (#1585)
- Closes #1513.
2026-05-22 08:56:25 -07:00
Erwan Legrand 831a6bfe1c fix: clamp ProgressBar barLength to non-negative value to avoid crash (#1525)
- Closes #1547.
- A negative progress value (e.g. from a race in progress events) would
produce a negative barLength and crash inside String(repeating:count:).
Wrap the computed length in max(0, ...) and add a regression test that
calls set(size: -10) and exercises draw(state:detail:).
2026-05-21 19:11:28 -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
AJ Emory afeceb05d4 Reorganize runtime targets for scalable plugin support (#1577)
## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Closes #1569

Separates generic runtime infrastructure from Linux-specific
implementation into distinct SPM targets:

- ContainerRuntimeClient — generic runtime plugin client API
- ContainerRuntimeLinuxClient — Linux-specific types
- ContainerRuntimeLinuxServer — Linux runtime service + interface
strategy implementations

Renames types to reflect the runtime/sandbox distinction:
- SandboxClient → RuntimeClient
- SandboxService → RuntimeService
- SandboxRoutes → RuntimeRoutes
- SandboxKeys → RuntimeKeys

Breaking for external consumers:
- ContainerSandboxService removed, replaced by ContainerRuntimeClient +
ContainerRuntimeLinuxServer
- Public types renamed

## Testing
- [x] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-05-20 12:57:10 -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
J Logan f8f7e2cdf0 Ensure read-only user config removed on every startup. (#1567)
- Closes #1566.
- Currently on `system start` we only remove the read-only user config
if the user config file exists. This means that changes to the config
are processed properly on restart, but a removal is ignored, and the old
read-only settings linger.
2026-05-15 19:43:24 -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
Shaurya Singh 64bd48bb9e Reject conflicting DNS flags (#1559)
Rejects conflicting DNS configuration when `--no-dns` is supplied
together with explicit DNS flags.

Fixes #1536.
2026-05-15 09:49:15 -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
AJ Emory 521df518e2 Add variant Support (#1548)
- This change adds two types to support opaque runtime
  data passing through the APIServer:
  - RuntimeConfiguration `data`
  - RuntimeLinuxData type
- LinuxRuntimeData defines runtime specific information.
  With this change, it will support `variant` only. The
  optional RuntimeConfiguration `data` field encodes
  runtime specific data to pass through the APIServer.
  It is decoded as needed by the runtime.
- The idea is to eventually move all runtime specific data
  into the `data` field so that the APIServer is only aware
  of generic container information.
2026-05-12 18:44:56 -07:00
J Logan b466959644 Remove IP allocation from API server. (#1545)
- Closes #1318.
- Closes #1378.
- Reduces the complexity and coupling for IP allocation.
- Runtimes connect to networks for the life of the running container.
The runtime shuts down on connection loss.
- Networks automatically deallocate a runtime's IP address and hostname
record on connection loss.
- Removes AllocatedAttachment as this is no longer necessary. The
`bootstrap()` XPC now takes a `NetworkBootstrapInfo` array which
parallels the attachments in the bundle config and provides the network
plugin attributes needed to create VM network interface configurations.

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

## Motivation and Context
Simplify IP allocation and make deallocation more reliable.

## Testing
- [x] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-05-12 16:34:06 -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
Chris George 940fefb7cd Use SystemPath for ContainerResource.Filesystem. (#1523)
- Closes #1521.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Same pattern as #1480 (HostDNSResolver) and #1518 (PacketFilter).
2026-05-12 12:35:02 -07:00
J Logan c56a659d33 Use allocate with session to automatically clean up IPs. (#1544)
- Part of #1318.
- Part of #1378.
- Removes network plugin `deallocate()`, and allocate takes an
`XPCServerSession` that registers an `onDisconnect` handler that
performs deallocation.
- ContainerService now tracks `networkSessions` for allocations.
2026-05-11 23:08:48 -07:00
J Logan 1794afc449 Adds XPC sessions with disconnect handlers. (#1524)
- Part of #1318.
- Part of #1378.
- `RouteHandler` now accepts an additional `XPCServerSession` which
include a disconnect handler.
- `XPCServer` configures a session for each client connection and passes
it to every route handler.
- `XPCServer.route(fn:)` can be used to wrap existing route handlers
that don't care about sessions.
- `XPCClient` adds functions to support client-side session handling.
- Update all existing routes.
2026-05-11 15:49:05 -07:00
Chris George 509fa047dc Use SystemPath for DirectoryWatcher. (#1522)
- Closes #1520.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Same pattern as #1480 (HostDNSResolver) and #1518 (PacketFilter).
2026-05-11 15:06:32 -07:00
Noah Thornton beb1592c04 swift-configuration decoder (#1447)
This adds a swift Decoder that decodes from a swift-configuration
ConfigSnapshot, and adds the ability to modify how select types are
decoded within the
ConfigSnapshotDecoder. This is something that JSONEncoder already does
with URLs specifically, however this enables users to configure this
behavior for any arbitrary type regardless of existing Codable
conformance.

The decoder will help us expand on top of (pr:
https://github.com/apple/container/pull/1425), which switches user
configuration to TOML. With this PR we will be able to provide a multi
layered TOML if desired, allowing container to ship a default TOML
instead of encoding them in code constants.
2026-05-08 17:06:04 -04:00
Chris George af8071bf04 Use SystemPath for PacketFilter. (#1518)
- Closes #1517.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Sibling of #1480 (HostDNSResolver), same pattern.
2026-05-08 12:58:02 -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 9f4e779421 Switch NetworksService, VolumesService, EntityStore to FilePath. (#1493)
- Closes #1485.
2026-05-01 14:39:03 -07:00
Danny Canter 06c00a93a2 CLI: Support --shm-size (#1488)
Closes #1484

Allows sizing /dev/shm
2026-04-30 16:10:25 -07:00
J Logan e6ba030fca Sort networks by ID in API server list(). (#1487)
Closes #1483.
Consistent well-defined behavior for server APIs.
2026-04-30 15:42:04 -07:00
J Logan 5ec28cffe5 Use SystemPath for HostDNSResolver. (#1480)
- Closes #1479.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
2026-04-30 15:01:12 -07:00