383 Commits

Author SHA1 Message Date
J Logan a18df81eb0 Select macOS 26 CI runners. (#1074)
- Runner fleet is on 26.3 now.
- Integration tests started flaking and it appears that we've been misconfiguring/not configuring proxy variables where we needed to be and it finally caught up with us. Workflow now adds appropriate exclusions for host-to-container and container-to-container network requests so they aren't all rammed through the proxy.
0.8.0
2026-01-21 18:25:39 -08:00
J Logan 2b18fc5870 Use StderrLogHandler for rich logging features. (#1066)
- Facilitates #507, #642.
- Plumb logger with logger option access into every command.
- StderrLogHandler allows logging to be enhanced for ANSI color mode for
log levels, JSONL log output, replacing `--debug` with `--level level`.
- Global logger is now just an Application.swift fileprivate only used
for initial args processing.
- Log with timestamp at debug and trace level.
- Metadata output is crude at present; we can refine this in a
follow-up.
2026-01-20 14:38:29 -08:00
J Logan a5607a8cf6 Update to containerization 0.21.1. (#1064)
- Picks up apple/containerization#478
2026-01-20 14:25:07 -08:00
Kathryn Baldauf 94d5529fc4 Use configuration subnet and fallback to default subnet in allocation only plugin (#1057)
## Type of Change
- [x] Bug fix

## Motivation and Context
This PR changes the behavior of the Allocation Only vmnet network plugin
to use the default subnet in the fallback case if no subnet was
specified in the network configuration. This matches the behavior of
`ReservedVmnetNetwork`.

## Testing
- [x] Tested locally
2026-01-19 19:23:06 -08:00
Kathryn Baldauf 9032d73d07 Change behavior of the default arguments in the plugin config (#1063)
## Type of Change
- [x] New feature  
- [x] Breaking change

## Motivation and Context
This PR changes the behavior of the `defaultArguments` field in the
service plugin config. Previously, `defaultArguments` was functioning as
a way to indicate how to start a plugin in the event that the plugin is
loaded at boot (such as for the `container-core-images plugin`).
However, we now follow a convention where all plugins have a "start"
command that is used when launching the plugin, so this
`defaultArguments` field wasn't really providing much. Instead, there
are use cases where we may want to set default values to pass to a
plugin. This PR repurposes the `defaultArguments` field for those use
cases.

As an example use case, there are scenarios where someone may want to
use the AllocationOnlyVmnetNetwork even when running on macOS 26+. This
PR adds the ability to pass in a command line option to the vmnet
network plugin to specify that request. Combined with the
`defaultArguments` plugin config change, a user may choose to set that
field to ["--variant", "allocationOnly"] in the
`container-network-vmnet-config.json` to use AllocationOnlyVmnetNetwork
by default for all networks.

## Testing
- [x] Tested locally
2026-01-19 19:22:55 -08:00
jwhur 69445b91b3 Throw error when starting a container with invalid virtiofs source (#1051)
Run = Create + Start

1) Mount source points to a valid directory
- Run and Create + Start both correctly create the container with mount.

2) Mount source points to a file
   - Run fails bootstrapping the container, thus container not created.
- Create creates the container, but Start fails bootstrapping, removing
the container. (Thus, both are the same.)

3) Mount source deleted or replaced to file after container created
   - Start throw errors but do not delete the container.
2026-01-19 13:09:34 -08:00
Danny Canter 08f48d9ab9 ContainerSvc: Handle unexpected sandbox svc exits (#1065)
Closes https://github.com/apple/container/issues/1050

If the sandbox svc exits out of band of the usual stop (or regular exit)
case the container svc's state is not properly updated for the
container. This was due to the cleanup steps involving trying to send
the shutdown rpc which cannot succeed as the sandbox svc does not exist
to service it.

To handle this, let's treat shutdown not returning successfully as
non-fatal (as this is mostly best effort), log an error and continue the
state cleanup.
2026-01-16 21:48:58 -08:00
Amir Alperin b928e3ff1d fix: performance warning should not output ANSI codes if stderr redirected (#1059) 2026-01-16 21:43:48 -08:00
J Logan 744e7f7c7a Update for containerization 0.21.0. (#1056)
- Update image load and build to handle rejected paths during tar
extraction. For the image load command there is now a `--force` function
that fails extractions with rejected paths when false, and just warns
about the rejected paths when true.
- Update `container stats` for statistics API properties now all being
optional.

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

## Motivation and Context
See above

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs
2026-01-16 16:26:13 -08:00
J Logan b1577d8d07 Adds opt-in pre-commit hook for format and header checks. (#1062)
- Closes #639.
- Adds swift format configuration that removes lint checks so we can use
`swift lint` to perform format-only tests.
- Adds `check` target that invokes format and header checks.
- Adds pre-commit script that runs `make check`.
- Adds `pre-commit` target that installs the check script as a
pre-commit hook.

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

## Motivation and Context
Avoids wasting time and commit rewrites.

## Testing
- [x] Tested locally
- [ ] Added/updated tests
- [x] Added/updated docs
2026-01-16 15:50:47 -08:00
J Logan 3cf2c6ad8d Fix unstable integration tests. (#1060)
- TestCLIRunCommand now run so many tests concurrently that the API
server gets swamped and tests randomly time out.
- The parallelism options on `swift test` only work for XCTest, not
swift-testing.
- Work around this while retaining some parallelism (good for stress
testing) by breaking the tests into two suites.
2026-01-16 13:41:32 -08:00
Manu Schiller 8897fcc4a0 fix: use pax instead of tar for pkg payload extraction (#1038)
- It is common to have `gnu-tar` alongside other GNU tools
  installed and aliased for compatibility reasons. However, this
  breaks the current make build.
- Use BSD-only binaries (no GNU equivalents that are
  commonly aliased), making the Makefile more portable.
2026-01-13 19:39:08 -08:00
Ronit Sabhaya dbec1db03e Add support for aarch64 architecture alias (#1040)
- Adds `aarch64` as an alias for `arm64` in the `Arch` enum. This
  addresses the maintainer's request to support this common architecture
  name, ensuring consistency with `x86_64` normalization and preventing
  failures for users expecting `aarch64` support.
2026-01-12 18:34:25 -08:00
jwhur 837aa5eb83 Fix the FS error when using Virtualization (#1041)
- Fixes #614.
- Use VZ cached mode instead of auto.

Signed-off-by: jwhur <jaewon_hur@apple.com>
2026-01-12 14:36:10 -08:00
박성근 e465b109b2 Fix relative path resolution in entrypoint (#987)
- Fixes #962.
- Adds test to exercise apple/containerization#473.
- Updates containerization to 0.20.1.

Signed-off-by: ParkSeongGeun <phd0801@naver.com>
2026-01-12 10:30:51 -08:00
Ronit Sabhaya aa7792807c Fix: Support x86_64 architecture alias to prevent silent pull failure… (#1036)
- Adds architecture name normalization to accept
  `x86_64` and `x86-64` as aliases for `amd64`.
2026-01-12 10:04:46 -08:00
Amir Alperin dc4682be74 fix: extract hostname from FQDN (#1011) (#1017)
- Set the container hostname to the first DNS
  label derived from the container id, strip everything
  after the first dot.
- Fixes #1011.
2026-01-09 11:10:53 -08:00
Ronit Sabhaya 4af1cc01c4 fix: improve error message when binding to privileged ports (fixes #978) (#1031)
- The container fails to start with a generic "permission denied"
  error when attempting to publish privileged ports (ports below
  1024) without root privileges. This provides a confusing user
  experience as the error doesn't explain why permission was
  denied.
2026-01-08 19:27:43 -08:00
J Logan 21facf00a8 Add instructions for using locally built init filesystem. (#1032)
- Closes #1030.
2026-01-08 17:02:22 -08:00
Danny Canter b671690c17 ProgressBar: Various fixes (#1025)
There's a couple things I don't think are intuitive about this.

1. Because of the internal task, render() can still be called even after
finish() completes. Ideally async defers are supported and we could just
await the final render completing after cancelling the task and setting
.finished, but alas. To fix this we can just lock across the methods for
now.
2. We always clear the screen in the destructor, even if we don't use
the
progress bar. I don't think we should honestly do anything in the
destructor.
Feels a programmer error not to defer { bar.finish() } or call it
somewhere.
3. Our spaces based line clearing. Use the ansi escape sequence for
clearing line;
I think our calculations were slightly off and it would leave trailing
output ( "s]" )
in some cases.
4. Shrinking the window until the output is smaller than the terminal
window (and vice
versa) is wonky on various term emulators. Truthfully, this is just a
hard problem,
but we can truncate our output and still provide some useful info.

This fixes some single line output (cat /etc/hostname etc.) getting
cleared in our atexit handler, as well as the need for the usleep.
2026-01-07 21:01:10 -08:00
J Logan 98410fdb57 Adds IPv6 port forwarding. (#1029)
- Closes #1006.
2026-01-07 18:23:31 -08:00
Saehej Kang 9d06475aaf [container]: add startedDate field (#1018)
- Closes #302.
- Closes #336 (obsoletes this PR).
2026-01-07 16:53:33 -08:00
J Logan db8932ab0f Resolve IPv6 address queries for container names. (#1016)
- Closes #1005.
- Adapt everything to use MACAddress type from containerization 0.20.0.
- Allocate MAC addresses for every container so that we have
deterministic IPv6 link local addresses.
- Add AAAA handling to ContainerDNSHandler.
- NOTE: Only works on Tahoe. On Sequoia, we don't have a good way to set
or determine the IPv6 network prefix when networks are created, so we
can't infer the IPv6 link local addresses for AAAA responses and we
instead return `NODATA`.
2026-01-07 15:35:35 -08:00
Danny Canter 5d6c750708 CLI: Add read-only flag to run/create (#999)
Closes #990 

Sets the rootfs for a container to read-only.
2026-01-07 14:48:58 -08:00
Danny Canter aac2457675 Tests: Fix relative path mount tests (#1028)
The tests are run in parallel on CI, and were split into three tests.
They change the cwd, so it's kind of a gamble whether some of them pass.
This just moves all the logic into one test mostly.
2026-01-07 13:46:26 -08:00
J Logan 9cd5397b8c Update to containerization 0.20.0. (#1027)
- Use MACAddress for Attachment and CZ interfaces.
- Move data validation closer to API surface.
2026-01-07 10:35:19 -08:00
J Logan 356c8d2f88 Reorganize client libraries. (#1020)
- Closes #461.
- Extract core types into ContainerResources target.
- Extract ContainerNetworkServiceClient from ContainerNetworkService.
- Relocate sandbox client from ContainerClient to
ContainerSandboxServiceClient.
- Relocate ContainerClient to ContainerAPIServiceClient.
- Common structure from services and clients under Source/Services.

Updated project hierarchy:

```
Sources/CAuditToken - audit token access wrapper
Sources/CLI - CLI executable
Sources/ContainerBuild - builder
Sources/ContainerCommands - CLI command implementations
Sources/ContainerLog - logging helpers
Sources/ContainerPersistence - persistent data and system property helpers
Sources/ContainerPlugin - plugin system
Sources/ContainerResource - resource (container, image, volume, network) types
Sources/ContainerVersion - version helpers
Sources/ContainerXPC - XPC helpers
Sources/CVersion - injected project version
Sources/DNSServer - container DNS resolver
Sources/Helpers - service executables
Sources/Services/*/Client - service clients
Sources/Services/*/Server - service implementations
Sources/SocketForwarder - port forwarding
Sources/TerminalProgress - progress bar
```

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

## Motivation and Context
The ContainerClient library was a bit of a grab bag. This refactor
applies a more sensible project and library structure for resource data
types, services, and clients.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-01-06 08:27:14 -08:00
Danny Canter 8c439cd356 makefile: Add cli target (#1022)
Often times I'll be making a change that only touches the cli and I
don't feel like sitting through the potential song and dance of the
other components building/installing.
2026-01-05 13:50:57 -08:00
Kathryn Baldauf d6f052d206 Update license header on all files to include the current year (#1024)
## Motivation and Context
Now that we're in 2026, we need to update the license headers on all the
files. Unfortunately, Hawkeye doesn't have an attribute for the current
year to help us avoid this in the future. Instead, I had to work around
this by doing the following:

1. Update licenserc.toml with:
     ```
      [properties]
       ... (other properties)
       currentYear = "2026"
     ```
 
2. Update scripts/license-header.txt with
    ```
Copyright ©{{ " " }}{%- set created = attrs.git_file_created_year or
attrs.disk_file_created_year -%}{%- set modified = props["currentYear"]
-%}{%- if created != modified -%} {{created}}-{{modified}}{%- else
-%}{{created}}{%- endif -%}{{ " " }}{{ props["copyrightOwner"] }}.
    ```

Then I removed these two changes before committing. After this PR is
merged, all files will have recently had git updates, so the existing
code for setting the modified year should work as intended.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2026-01-05 13:09:34 -08:00
Danny Canter 20dc0bcfee Parser: Support relative paths for --volume (#1013) 2026-01-04 11:11:09 -08:00
Danny Canter 028e7e109f Deps: Bump Containerization to 0.19.0 (#1015)
Has read-only rootfs support.
2026-01-04 10:52:46 -08:00
Danny Canter 020949ea2b CLI: Small fixups for implicit envvars (#1014)
We should only inherit from the host if there's no =. Additionally
document the flag a little more to show that we can inherit from the
host.
2026-01-04 10:51:20 -08:00
Amir Alperin df368b790e Fix port validation to allow same port for different protocols (#992) (#1000)
- Fixes: #992 
- Port validation previously rejected valid configurations
  when the same port number was used for different
  protocols (TCP and UDP). For example:
 `-p 1024:1024/udp -p 1024:1024/tcp`
  Although this is a valid and common use case, the
  validation logic treated it as a conflict.

To fix this, I updated the validation key to include the protocol name.
The validation now checks for overlapping port numbers only within the
same protocol, rather than across all protocols.

This change enables binding the same port number for both TCP and UDP,
aligning the validation behavior with real-world networking
requirements.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs
2026-01-04 10:49:22 -08:00
J Logan cf64614173 Update OSS header in Package.swift. (#1010) 2026-01-02 14:10:48 -08:00
J Logan 375ce16a99 Fix OSS header dates that break CI checks. (#1009) 2026-01-02 12:09:12 -08:00
c 580d8531c0 Use full path for uninstall script in upgrade instructions (#983)
- Makes the upgrade section consistent with the
  uninstall section by using the full path to the
  uninstall script.
2026-01-01 21:19:57 -08:00
c 4cadc401e1 Clarify uninstall script location in README (#982)
- Clarifies where the `uninstall-container.sh` script is located after
installation
- Updates example commands to use the full path
2026-01-01 19:53:56 -08:00
c 4e78e30b20 Fix grammar in tutorial.md (#985)
## Summary
- Fixes a grammar error in the tutorial's publish section

## Details
Line 287 of `docs/tutorial.md` had "you need push images" which should
be "you need to push images".

This is a simple grammar fix to improve readability.

## Test plan
- [x] Verified the sentence now reads correctly
2026-01-01 17:57:47 -08:00
Danny Canter 22dfd6e7c7 CLI: Fix stop not signalling waiters (#972) 2026-01-01 17:57:00 -08:00
c 4958cf272f Fix bash completion source path in documentation (#981)
- Corrects the source path for bash completion script
  when not using bash-completion package.
2026-01-01 17:51:10 -08:00
c 25ac79a0c4 Fix MAC address option typo in how-to documentation (#980)
- Corrects the MAC address example command in the
  how-to guide to use the correct `--network` flag syntax
  instead of the incorrect `--mac-address` flag.
2026-01-01 17:50:19 -08:00
Raj edadf155cd Fix container auto-delete on rapid stop/start (#841)
Fixes #833.

Currently, when stopping and immediately restarting a container, it would fail with the error:
`“container expected to be in created state, got: shuttingDown”` and then be automatically deleted.
The `SandboxService` process waits five seconds before exiting after shutdown. During this interval, a rapid restart could reconnect to the still-terminating process in the `shuttingDown` state, triggering a state validation error.

This fix forcefully terminates the `SandboxService` process with `SIGKILL` upon container exit, instead of waiting five seconds. The bootstrap now defensively checks for and cleans up any stale services before registering new ones, preventing reconnections to processes in the `shuttingDown` state.
2026-01-01 01:40:39 -08:00
J Logan 5064b0ffd5 Adds network IPv6 configuration. (#975)
- Part of work for #460.
- Enable set/get of IPv6 network prefix in ReservedVmnetNetwork.
- Show IPv6 prefix in `network list` full output.
- Option for setting IPv6 prefix when creating a network.
- System property for default IPv6 prefix.

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

## Motivation and Context
See #460.

## Testing
- [x] Tested locally
- [ ] Added/updated tests
- [x] Added/updated docs
2025-12-22 10:16:14 -08:00
Volodymyr Bortniak 9c239aa36c Add support for reading env from named pipes (#974)
This is a fix for
[issue#956](https://github.com/apple/container/issues/956)

`FileManager.default.contents(atPath:)` returns `nil` for named pipes
(FIFOs)
and process substitutions like `/dev/fd/XX` because:
1. It expects regular files with a known size
2. Named pipes are stream-based and block until data arrives

## Solution
Use `FileHandle(forReadingFrom:)` instead, which:
- Properly handles blocking I/O
- Works with named pipes, process substitutions, and regular files
(mentioned in the
[doc](https://developer.apple.com/documentation/foundation/filehandle))

Co-authored-by: Bortniak Volodymyr <Bortnyak@users.noreply.github.com>
2025-12-19 15:36:02 -08:00
Danny Canter 3c3a83c98a Turn on oops=panic kernel cmdline (#971) 2025-12-18 16:28:44 -08:00
Michael Gathara b1b99809d4 Fix: Kubes Cluster in Container Crashing Container (IS#923) (#930)
- Fixes issue #923 
- I fixed a race condition in `ConnectHandler.swift` where
  an asynchronous network connection could complete
  after the handler had already been removed from the
  pipeline.
- This prevents the EXC_BREAKPOINT crash in
  container-runtime-linux that occurred when kinc
  (Kubernetes in Container) created rapid connections.
- The actual fix was inadvertently applied in #957, so this
  PR contains only the test code.
2025-12-17 18:58:50 -08:00
Saehej Kang 9f4efe0c4c [networks]: add prune command (#914)
- Closes #893
2025-12-17 00:30:33 -08:00
J Logan 4f88725158 Use new IP/CIDR types from Containerization. (#957)
- Part of work for #460.
- With CZ release 0.17.0, the IP and CIDR address
  types changed from String to IPv4Address and
  CIDRv4, respectively. This PR applies the corresponding
  adaptations to container.
2025-12-16 16:34:13 -08:00
Salman Chishti 8e16bb239e Upgrade GitHub Actions to latest versions (#959)
- Upgrade GitHub Actions to their latest versions for
  improved features, bug fixes, and security updates.

Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>
2025-12-16 12:14:45 -08:00
Salman Chishti 0c7dca4d25 Add Dependabot for GitHub Actions updates (#960)
## Summary

Add Dependabot configuration to automatically keep GitHub Actions up to
date.

## Changes

Adds `.github/dependabot.yml` configured to:
- Check for GitHub Actions updates weekly
- Group all action updates together for easier review
- Use `ci` prefix for commit messages

## Why

As discussed in #958, this helps:
- Keep actions up to date with security patches automatically
- Handle Node runtime deprecations proactively (e.g., Node 20 → Node 24)
- Reduce manual maintenance burden

## Reference

Based on the pattern used in
[swift-nio](https://github.com/apple/swift-nio/blob/main/.github/dependabot.yml).
2025-12-16 11:23:31 -08:00