72 Commits

Author SHA1 Message Date
Danny Canter 3fcf647c7b Add virtualization support for containers (#377) 2025-07-30 11:14:41 -07:00
Kathryn Baldauf 047c1afe96 Fix user arg passthrough for container create (#393)
This matches other container commands that rely on user arguments at the
end, such as `container run`. Closes #395.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-07-29 13:54:12 -07:00
Danny Canter ccd15edc16 Bump Containerization to 0.5.0 (#363)
0.5.0 introduces a new way to configure the containers and execs. This
is now done all upfront at constructor time in a callback style. I'm
very happy with the config improvements, but because IO can only be
setup at constructor time this makes it so that we need to supply IO at
creation time of the VM or exec, which isn't the end of the world. All
that really changes is `boostrap()` and `createProcess()` now take in IO
instead of slightly later in `process.start()`
2025-07-29 16:02:19 -04:00
Sidhartha Mani cc4a85bb09 add support for local build output (#369)
Fixes https://github.com/apple/container/issues/354
2025-07-23 15:59:28 -07:00
J Logan f0eda65a20 Applies feedback for PR #352. (#365)
- Forgot to commit the changes to gracefully shut down the event loop
group used by the port forwards.
2025-07-23 12:10:59 -07:00
J Logan eea8cb6709 Adds --publish flag for forwarding traffic to container ports. (#352) 2025-07-23 00:28:41 -07:00
Danny Canter c0d1f8fb11 CLI: Handle stdin stream if it's a regular file (#322)
readabilityHandler is a bit crummy if it's a regular file. This just
writes our own loop and exits and shuts down the write end of the pipe
if we get to the end of the file.
2025-07-22 13:33:11 -07:00
Kathryn Baldauf 8002eec249 Add cause string to error message sent with xpc (#361)
Looks like we've been ignoring the "cause" field for
ContainerizationError when sent over xpc. Add the cause to the
`ContainerXPCError` message field instead of a new `cause` field since
`Error` is not encodable. The goal here is just to preserve information.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-07-21 15:04:28 -07:00
J Logan 0ef36d470b Use wildcard IP for UDP backend local address. (#359) 2025-07-19 00:15:53 -07:00
Sidhartha Mani f68919c137 [Build] fixes for tar output mode (#353)
Fixes https://github.com/apple/container/issues/347
2025-07-18 16:50:11 -07:00
J Logan 1de3036f9a Adds TCP and UDP port forwarders. (#338) 2025-07-18 12:08:52 -07:00
J Logan 2e1bee1bda Fix subcommand groups in top level help. (#351)
- Closes #349.
2025-07-17 22:10:03 -07:00
Typ0genius 8053e9f16b Make image details public (#335)
I want to access the different variants of an image in my app, which
information is only available in the ImageDetail. Although the function
ClientImage.details() -> ImageDetail and its return type are already
public, its properties aren’t, which prevents access to this
information.
2025-07-16 17:03:46 -07:00
J Logan 1707e1b530 Use {install-root}/libexec/container-plugins for plugins. (#341)
- Use a directory that's separate from user data, as user-installed
plugins have a distinct lifecycle.
- Closes #340.
2025-07-15 18:18:38 -07:00
Dmitry Kovba f889c1bf76 Use the new @SendablePropertyUnchecked macro (#332)
Changes in this PR require merging
https://github.com/apple/containerization/pull/212 in containerization
and creating a new tag.
2025-07-14 16:57:55 -07:00
Dmitry Kovba c41a8883ea Use Mutex for thread-safe access to structs (#325)
Changes in this PR prevent a race caused by an implicit call to a
computed property getter when updating the property value.
2025-07-14 15:23:35 -07:00
Kathryn Baldauf f0d82d2032 Handle when keychain query returns an unhandled error (#331)
Depends on https://github.com/apple/containerization/pull/210
Related to https://github.com/apple/container/issues/254

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-07-14 14:52:12 -07:00
Danny Canter 66a6974c6d ProcessIO: Don't error if stdin isn't a pty and !-i (#312)
We don't need to error unless we're supplying io.
2025-07-08 16:29:34 -07:00
J Logan f22674156c Flush output when following logs. (#316)
- Closes #315.
2025-07-08 16:01:22 -07:00
Arnav Reddy a7799d02e3 Mark SandboxSnapshot init as public for sandbox plugins (#309)
Changed `SandboxSnapshot` initializer from `package init()` to `public
init()` to enable external package consumers to create and use
`SandboxSnapshot` instances in their custom Sandbox plugins.

The `SandboxSnapshot` is used for `container list` functionality
2025-07-08 14:17:17 -07:00
Sidhartha Mani 6d804620a5 [Build] Disable rosetta during builds with a UserDefault (#273)
Fixes https://github.com/apple/container/issues/103
2025-07-01 14:52:41 -07:00
J Logan 75e92853e3 Assigns default nameserver in sandbox service. (#276)
* Closes #148.
* Storing the default nameserver in the bundle config means that DNS
won't work if the container stops and then restarts later when the
subnet address has changed.
2025-07-01 10:03:23 -07:00
Eliseo Martelli 48db62376d Use enum for ClientHealthCheck namespace (#225)
Switch `ClientHealthCheck` from a `struct` to an `enum` to prevent
instantiation.
2025-07-01 12:55:49 -04:00
Aditya Ramani 4bfa6c29ec Add unpack strategy to SnapshotStore (#274)
Define a `UnpackStrategy` function type in the `SnapshotStore` to give
more control over how an image is unpacked.

Previously, we were creating a 512 GB sparse block file for the initial
file system of a container, which is overkill.

With this change, the vminit image is unpacked to a smaller block file,
while container images are unpacked to the 512 GB block

Follows the same pattern as
https://github.com/apple/container/blob/main/Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper.swift#L71

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-07-01 11:22:22 -04:00
J Logan 3b5c253059 Adds container network for macOS 26. (#243)
See discussion below for example. For multiple network interfaces in a
single container we'll want to integrate against a containerization that
includes apple/containerization#156.

The change bumps the containerization dependency to 0.2.0 and addresses
the breaking API changes.

```console
% container network
OVERVIEW: Manage container networks

USAGE: container network <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  create                  Create a new network
  delete, rm              Delete one or more networks
  list, ls                List networks
  inspect                 Display information about one or more networks

  See 'container help network <subcommand>' for detailed help.
```
2025-06-27 14:12:29 -07:00
Eliseo Martelli b5589f7f8c Improve error handling in answerHost (#226)
Refactor `answerHost` to throw descriptive `DNSResolverError` instances
instead of returning nil when IP allocation or parsing fails.
2025-06-27 10:29:25 -07:00
Dmitry Kovba de2be705de Remove the support for CURRENT_SDK (#251)
This PR removes the no longer needed support for `CURRENT_SDK`.
2025-06-26 10:40:34 -04:00
Sidhartha Mani c7c88c2e34 [Build] Do not use unbounded DispatchIO readers for tar tranfers (#257)
- Addresses https://github.com/apple/container/issues/166
- Memory utilization explodes since there is no mechanism for
backpressure
- Using a synchronous buffered reader seem to provide similar
performance without the memory explosion issue
- 4MB buffer seems to provide the best results

| Metric | 1MB Buffer | 4MB Buffer | Unbounded Zero-Copy |

|--------------------------|------------|------------|---------------------|
| Build Time | 149.33s | 138.57s | 139.79s |
| Max RAM Used | 2.16 GB | 3.02 GB | 3.52 GB |
| Peak Memory Footprint | 8.30 GB | 8.17 GB | 10.21 GB |
| Page Reclaims | 1,085,559 | 1,039,677 | 1,619,943 |
| Page Faults | 115 | 148 | 143 |
| CPU Usage (User+Sys) | 53.71s | 53.12s | 60.44s |
2025-06-25 13:51:51 -07:00
Kathryn Baldauf 4a6a1f15d8 Add test that we replace meta args in builder correctly (#255)
Depends on https://github.com/apple/container-builder-shim/pull/24 

Related to https://github.com/apple/container/issues/252

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-24 13:25:58 -07:00
Renee Chang a69ed78484 Add socket publishing functionality (#236)
Signed-off-by: renee chang <rchang25@apple.com>
2025-06-20 09:00:47 -07:00
Spencer Heywood a262d8fc6a provide suggestion if xpc 'Connection invalid' error encountered (#179)
Closes https://github.com/apple/container/issues/80

Adds the following help message if you try to run `container` against a
host that hasn't started the container system:

```
❯ /usr/local/bin/container list
Error: internalError: "failed to list containers" (cause: "interrupted: "Connection invalid: ensure container system has been started with `container system start`"")

❯ /usr/local/bin/container run -it --rm docker.io/alpine
Error: interrupted: "Connection invalid: ensure container system has been started with `container system start`"
```
2025-06-19 00:12:57 -07:00
Ramsyana 21cfebb475 Fix Race Condition in Container Removal (#130) (#218)
This PR resolves a race condition when removing a container immediately
after stopping it, caused by the `stop` command returning before the
container fully transitions to the stopped state (#130).

**Changes:**
- Enhanced `TestCLIRmRace.swift` with robust test logic and helper
methods (`containerExists`, `safeRemove`).
- Improved error handling to distinguish race conditions from successful
removals.
- Added exponential backoff retry logic for cleanup operations.
- Updated `CLITest.swift` with missing `doRemove` method.
- Fixed `BuilderStart.swift` to handle `.stopping` case.
- Improved error messages with container ID for better debugging.

**Testing:**
-  All tests pass (`make test`, `make integration`).
-  Verified on macOS 26.
-  Race condition test validates success and failure scenarios.
-  Code formatted (`make fmt`).

Hopefully, this will pass the integration tests on GitHub.

Signed-off-by: ramsyana <47033578+ramsyana@users.noreply.github.com>
2025-06-16 23:19:46 -07:00
Dmitry Kovba 0535d36929 Fix warnings in make docs (#220) 2025-06-16 17:55:48 -07:00
Aditya Ramani 4c171d4641 Wait for IO streams to complete before a process exits (#198)
Implements a way for the CLI to wait until the IO streams from the
SandboxService have been drained before closing them.

Follows the same pattern as
https://github.com/apple/containerization/pull/110

This change also performs some cleanup in the
`SandboxService.startProcess` method - splitting the code paths to
handle the init process and an exec'd process into two different private
methods to make easier reading

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-16 13:41:56 -07:00
Michael Crosby 011e6764f7 use rotatingAllocator for ipam (#217)
Signed-off-by: crosbymichael <michael_crosby@apple.com>
2025-06-16 11:03:57 -07:00
Josh Soref 4a4ad40d74 Spelling (#207)
This PR corrects misspellings identified by the [check-spelling
action](https://github.com/marketplace/actions/check-spelling)

The misspellings have been reported at
https://github.com/jsoref/container/actions/runs/15662939575/attempts/1
The action reports that the changes in this PR would make it happy:
https://github.com/jsoref/container/actions/runs/15662939742/attempts/1#summary-44123289718

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2025-06-16 10:49:03 -07:00
Danny Canter 4d6f7037f3 Plugins: Remove unused devnull var (#214)
We actually use the output (both stderr and stdout) of the command.
2025-06-16 08:11:25 -07:00
Dmitry Kovba 555dbfc9fa Adds a warning when running a debug build (#201)
This PR adds a warning that the performance may be degraded when running
a debug build.

Debug build:
```
% bin/container run -it --rm alpine:latest date
Warning! Running debug build. Performance may be degraded.
Fri Jun 13 18:10:35 PDT 2025
```

Release build:
```
% bin/container run -it --rm alpine:latest date
Fri Jun 13 18:10:35 PDT 2025
```
2025-06-13 19:48:59 -07:00
Eliseo Martelli 84798601cd Throw errors in ServiceManager (#188) 2025-06-13 17:07:55 -07:00
Noritaka Kobayashi 098021fc5b refactor: fix typos (#77)
fix typos
2025-06-13 16:42:07 -07:00
Aditya Ramani c5392e838f Remove the system restart command (#196)
Closes https://github.com/apple/container/issues/175

Also does some housekeeping - update availability checks and fix a typo

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-13 13:45:25 -07:00
Patrick Stöckle 84edaa20db Fix typos (#122)
Hi there,

some small typos I fixed using
[`typos`](https://github.com/crate-ci/typos).

Cheers,
Patrick
2025-06-13 11:07:07 -07:00
Alexey Makhov 2a12f01d32 container registry login host:port error fix (#170)
Fixes #121

Gets port from the given registry server URL and use it in a
RegistryClient.

Signed-off-by: Alexey Makhov <makhov.alex@gmail.com>
2025-06-13 07:33:05 -07:00
Dmitry Kovba 206f3cc07c Improve accuracy of progress updates (#144)
This PR resolves the problem of dropped progress updates and ensures the
accuracy of the information provided in the progress bar. Additionally,
it adds the displaying of the finished state to the progress bar.
Requires merging and tagging
https://github.com/apple/containerization/pull/91.
2025-06-12 23:36:38 -07:00
Yibo Zhuang 8f2d4d7300 Fix: consolidate UserDefaults service name (#161)
This change consolidates the UserDefaults service name
`com.apple.container.defaults` to a single constant under the extension
file and also renamed the extension file.

Signed-off-by: Yibo Zhuang <yibzhuang@gmail.com>
2025-06-12 21:28:24 -07:00
Ümit DEMİRCİ c114945f15 fix: typo (#153) 2025-06-12 17:14:15 -07:00
Elijah Wright 7ca5a4313f define JSONDecoder() outside of for loop in load() (#159)
this PR defines a variable, `decoder`, which represents the
`JSONDecoder` class, rather than doing it in the for loop in `load()`

Signed-off-by: Elijah Wright <git@elijahs.space>
2025-06-12 11:37:26 -07:00
Kathryn Baldauf 3838be5207 Update protos and add builder shim version in Package.swift (#176)
This PR updates the protos to match the recent changes in
https://github.com/apple/container-builder-shim/pull/15.

This PR additionally adds the builder shim version as a variable in
Package.swift. This allows us to be consistent with the builder tag used
for the builder shim image and when building protobuf files.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-12 10:51:00 -07:00
Kathryn Baldauf 37fc68fee0 Add the option to disable progress updates on image CLI calls (#146)
Closes https://github.com/apple/container/issues/126 

This PR additionally removes the ability to set
`disable-progress-updates` for `container create` calls while we
investigate why output get jumbled there.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-11 13:12:10 -07:00
Daniel Gonzalez 20b63255ac Add new system status command (#118)
Container services can be started and stopped using the `system start`
and `system stop` commands. But there is no straightforward way for
users to check if the services were already started.

This PR adds a new `system status` command that shows wether the
container services are running or not.

The command only checks the status of the apiserver for now, but it
could be expanded in the future to show more details.

Fixes #117.
2025-06-10 16:30:59 -07:00