Commit Graph

558 Commits

Author SHA1 Message Date
Saehej Kang 2ee3f3d0a1 [scripts]: add prompt for updating container with unsigned package (#1468)
Closes #1467 and some minor QOL updates
2026-05-01 17:04:35 -07:00
J Logan 9f4e779421 Switch NetworksService, VolumesService, EntityStore to FilePath. (#1493)
- Closes #1485.
2026-05-01 14:39:03 -07:00
Kathryn Baldauf e57c755911 Simplify the serial suite trait (#1497)
## Motivation and Context
The `SuiteGate` actor introduced for the serial test trait in
https://github.com/apple/container/pull/1489 could be simplified using
containerization's
[AsyncLock](https://github.com/apple/containerization/blob/f2c42402e744df992fecb84eb3a82935c6fa01d3/Sources/ContainerizationExtras/AsyncLock.swift#L23).

## Testing
- [ ] Tested locally

Note: working on A/B performance testing to validate this approach does
not significantly impact test run performance.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-05-01 11:38:07 -07:00
Noah Thornton a141002de1 Improve integration test speed (#1489)
This improves the integration test suite speed by running all
integration tests in a single `swift test` invocation. We maintain the
one `@Suite` at a time behavior by introducing a new test trait that
uses a single mutex to limit inter-suite parallelism.
2026-04-30 16:20:06 -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 1ee2d9d054 Update documents with note about container-to-host networking. (#1482)
- Currently we need to use `pfctl` to create the packet filter rule for
container-to-host networking (`host.docker.internal`). This approach
unfortunately has a few limitations that require documentation.
2026-04-30 15:05:10 -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
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
Matt Van Horn b73933eb2d Tests/CLITests: drain stdout/stderr concurrently in CLITest.run (#1471)
## Type of Change
- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context

`CLITest.run(arguments:stdin:currentDirectory:env:)` reads stdout to EOF
before stderr begins draining
(`Tests/CLITests/Utilities/CLITest.swift:182-183`). If a child process
writes more than a pipe-buffer's worth of data to stderr (~64 KB on
macOS), the child blocks in `write()` on stderr while we block in
`readDataToEndOfFile()` on stdout, and neither side makes progress until
`process.waitUntilExit()` returns. This is a latent deadlock that any
future test or CLI verbosity bump can trigger.

This PR drains both streams concurrently using `readabilityHandler`
closures backed by `Mutex<Data>` buffers. After
`process.waitUntilExit()` returns the handlers are cleared and
`readDataToEndOfFile()` flushes any bytes the kernel buffered between
the last handler invocation and exit. The error path also clears
handlers so a failed `process.run()` does not leak callbacks. `Mutex`
matches the locking primitive the file already uses for `commandSeq`.

Fixes #1456

## Testing

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

`swift build --target CLITests` passes against the change. `make
swift-fmt-check` is clean. Behavior is unchanged for any test command
that previously fit within a single pipe buffer, so the existing
CLITests still exercise the helper end-to-end.

I did not add a new test that emits >64 KB to stderr because every
existing CLITest invocation goes through `executablePath` (the
`container` binary), and reproducing the deadlock requires a child that
emits a controllable amount on stderr. Happy to follow up with a small
refactor that extracts the drain into a static helper plus a regression
test that drives it via `/bin/sh` if that would be useful.

---------

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
2026-04-30 10:28:27 -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>
0.12.3
2026-04-30 09:33:26 -05:00
Patrick Linnane fd2de35440 ensure-container-stopped.sh: don't fail on launchctl errors (#1461)
- Fixes #1281. Supersedes #1306.
- When `-a` runs as a regular user (such as via
  `brew install container`), two launchctl failures
  bubble up as a non-zero exit and break Homebrew's
  post-install:
  - `bootout` against `system` requires root.
  - `launchctl print` lists Mach endpoint names that
    aren't loaded jobs, so `bootout` returns
    `No such process` on them.
- Skip `system` when not root, and treat individual
  `bootout` failures as non-fatal. Same fix applied to
  the non-`-a` `xargs` pipeline.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-04-29 19:42:49 -07: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 4e390d6aa8 Fix RequestScheme formatting. (#1473)
## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
`main` build broke with last commit.

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

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
Co-authored-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-04-29 15:04:24 -07:00
J Logan 601f5f113a Merge commit from fork
- Don't prefix match localhost, use exact
  match only.
- Only check default local domain if one is
  defined.
- Use IPv4Address for private IP CIDR tests.
2026-04-29 11:46:22 -05:00
Kathryn Baldauf e9891b3cfe Allow macOS 15 to list and delete networks (#1464)
- A recent change moved the list and delete
  network XPC calls within an availability check,
  making them only available on macOS 26.
  However, there are some code flows that rely
  on being able to call `list` on the NetworksService,
  including anything that uses `networkClient.builtin`.
- `container` does not officially support macOS 15
  and as a result we do not have GitHub action runners
  for validation on macOS 15. That said, we try to avoid
  breaking compatibility on macOS 15 as much as
  possible.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
0.12.2 0.12.1
2026-04-28 18:26:34 -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.
0.12.0
2026-04-27 11:32:00 -07:00
Kathryn Baldauf df25fe25bb Add yams to apple/container's notice file (#1442)
This PR adds yams to the NOTICE file. Yams was introduced in
https://github.com/apple/container/pull/1353.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-04-22 16:08:07 -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
jwhur 49e93cb1a9 Change guest ssh socket path (#1441)
Changes ssh socket path in container to
`/var/host-services/ssh-auth.sock` as the path `/run` (where the ssh
socket is mounted initially) is often mounted again by init systems, and
the ssh socket is hidden.

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

## Motivation and Context
Makes ssh socket forwarding reliable.

## Testing
- [X] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-22 14:12:06 -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
Kathryn Baldauf 1138c0950b Create a NOTICE file for apple/container's dependencies (#1436)
## Motivation and Context
This PR adds the legal attributions for the direct dependencies of
apple/container.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-04-22 09:42:32 -07:00
J Logan 86611f588b Adds journal option to container volume create. (#1412)
- Closes #1411.
- Default behavior doesn't change today - with no `journal` option, no
journal gets created.
2026-04-22 09:34:24 -07:00
Ronit Sabhaya 2e029c82ce Fix: memory leak and silent read error in Archiver._compressFile causing build failures under /Users/ (#1432)
- Closes #1439.
- May also address some cases of #1423.
- `_compressFile()` allocated a 1 MiB read buffer
  per file but never freed it.
- It also treated InputStream.read() errors (-1) the
  same as EOF (0), silently swallowing errors such
  as TCC access denials under /Users/, which could
  result in unexpected archive contents.
2026-04-22 08:10:47 -07:00
J Logan ae0fa26f6b Updates containerization dependency to 0.31.0. (#1435)
- Fixes single file mounts. Closes #1251.
- Adds journal modes to `EXT4.Formatter`.
- vminitd fix for client timeouts resulting in EBADF and other minor
improvements.
- Reenable block size for EXT4 formatter, and other fixes.
- Update vminit client and server to grpc-swift-2.
2026-04-21 16:50:56 -07:00
Noah Thornton d4691e2830 Explicitly pass default subnets into network creation (#1424)
This changes the semantics around `ReservedVmnetNetwork` and
`AllocationOnlyVmnetNetwork` to only create ipv4/6 subnets for networks
when the values are explicitly passed in the `NetworkConfiguration`.
Previously if the values in the `NetworkConfiguration` were not present
it would attempt to source them via `DefaultsStore`.


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

## Motivation and Context

The change solves an issue that caused `container network create <name>`
to fail when `UserDefaults` was set to a value that is identical to the
hard coded default ("192.168.64.1/24"/"fd00::/64"). It would fail
because a network with these parameters would already exist, and thus
could not be reserved.

## Testing
- [X] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-21 14:33:26 -07:00
Saehej Kang 049570052c [build]: add tests for copy from (#1380)
## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context

Relates to #1240

Test cases added for validation based on changes from
apple/container-builder-shim#73.

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

---------

Co-authored-by: jwhur <57657645+JaewonHur@users.noreply.github.com>
2026-04-21 14:30:04 -07:00
Noah Thornton 7e8c2fe894 Add unit and integration coverage report make targets (#1427)
This adds make targets that generate json, html, and plain text coverage
reports for unit tests, integration tests, and an aggregation of both
suites. These new targets can be run via `make coverage` (aggregate),
`make coverage-unit` (only unit tests), and `make coverage-integration`
(only integration tests).

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

## Motivation and Context
This provides developers a means to measure test coverage for new and
old features alike, to ensure that testing for aforementinoed features
is adequate.

## Testing
- [X] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs
2026-04-21 11:18:23 -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
J Logan acfbf2d2db Update kernel to kata-3.28.0. (#1431) 2026-04-20 15:22:28 -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
Vitor Hugo 8567d8a97b stats: restore terminal when streaming is interrupted by a signal (#1355)
When `container stats` runs in streaming mode, pressing Ctrl+C sends
SIGINT directly to the process before Swift can run the `defer` block
responsible for restoring the terminal. This leaves the alternate screen
buffer active and the cursor hidden after exit.

Fix this by wrapping the streaming loop in a `withThrowingTaskGroup`
that races the work against an `AsyncSignalHandler` for SIGINT and
SIGTERM. When a signal arrives, the group is cancelled through normal
Swift unwinding, allowing the `defer` to execute and restore the
terminal correctly. This follows the same pattern used in
`BuildCommand`.

`runStreaming`, `collectStats`, `printStatsTable`, and `clearScreen` are
promoted to static methods since none of them read instance state, which
is required to safely capture only the `containers` value in the task
closure under Swift 6 strict concurrency.

Fixes #1351
2026-04-20 10:26:22 -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
dependabot[bot] e710876ac8 ci: bump the github-actions group with 3 updates (#1419)
- Updates `actions/upload-artifact` from 7.0.0 to 7.0.1
- Updates `actions/upload-pages-artifact` from 4 to 5
- Updates `softprops/action-gh-release` from 2 to 3

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-15 11:00:39 +01:00
Anthony 23169055b9 Fix ContainerResource build failure (#1408)
The `ContainerResource` target uses `OrderedDictionary` (added in #1360)
but doesn't declare a dependency on `swift-collections` in
`Package.swift`, and the source files import the `Collections` umbrella
module instead of `OrderedCollections`. This causes build failures when
`OrderedDictionary` is used in public declarations, since the compiler
requires the specific submodule to be imported in that context.

- Add `swift-collections` dependency to the `ContainerResource` target
in `Package.swift`
- Change `import Collections` to `import OrderedCollections` in
`ApplicationError.swift` and `ResourceLabels.swift`
2026-04-13 11:18:42 -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
Aditya Ramani 6b950f4881 Write file data into archive only for regular files (#1403)
## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
Closes https://github.com/apple/container/issues/1375

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

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2026-04-08 15:07:46 -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
J Logan e37dcc19a5 Create ResourceLabels and use for ManagedResource, NetworkConfiguration. (#1360)
- Closes #1359.
- Create a ResourceLabels type and extract the label validation from
NetworkConfiguration into the new type.
- Create a base AppError type that is compatible with structured logging
and delegates message presentation to the error receiver.
- Define LabelError over AppError for label validation.
- Slightly reworks NetworkConfiguration entity migration code in
NetworksService.
2026-04-07 16:31:18 -07:00
Kathryn Baldauf af43a8b256 Move exit status check into ExitWaiter register call (#1397)
## Motivation and Context
This PR just simplifies some of the ExitWaiter helper functions on
SandboxService by moving the exitStatus check into the ExitWaiter class
itself.

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-04-07 16:23:50 -07:00
Raj 3366916e80 Consolidate CLI formatting infrastructure (#1385)
## Motivation and Context
This PR consolidates duplicated list-output formatting across the CLI
into shared rendering infrastructure.

Currently, each list command has its own copy of the same
json/quiet/table branching. This PR pulls that into shared rendering
infrastructure in `ContainerCommands`:
- `ListDisplayable` protocol for table + quiet output
- `renderJSON`, `renderTable`, `renderList` as pure functions that
return strings
- `emit()` as the single stdout boundary (no-ops on empty strings to
avoid blank-line regressions)
- `JSONOptions` so all JSON encoding goes through one path, including
volume inspect's pretty + ISO 8601 case

JSON encoding remains separate from display formatting: each command
still chooses its own JSON model, while `ListDisplayable` is used only
for table and quiet output. `ImageList` remains the intentional
exception for quiet mode so it can avoid unnecessary async work.

This change also replaces inline `JSONEncoder` usage with `renderJSON`,
removes the old `Codable+JSON.swift` helper, and moves `TableOutput` and
`ListFormat` into `ContainerCommands`. It also adds unit tests for the
shared rendering helpers and expands integration coverage for image,
network, and registry list formatting.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-04-07 09:50:51 -07:00
Aditya Ramani f0e85c4ac7 Bump containerization to 0.30.1 (#1396)
Pick up bug fixes in containerization
2026-04-06 12:20:22 -07:00
ChengHao Yang ef993894f7 feat: add help for cli plugin (#1068)
- Closes #387.
- Override the swift-argument-parser `help` command
  with a version that prints the reformatted help that
  includes plugin information.

---------

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2026-04-04 19:29:34 -07:00