Commit Graph
129 Commits
Author SHA1 Message Date
Aditya Ramani b24b72a7e4 Reference image via sha for test (#190)
CI was failing since the test image we use had a tag re-pushed. Pinning
the test to reference the image version by its sha

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-07-01 17:58:40 -07:00
Danny Canter 61b01cc1ee LCShim: Add CZ prefixes/pidfd wrappers (#189)
We should namespace these a bit, and we need pidfd for some upcoming
terminal work. This also just gets rid of syscall2 and replaces with a
pivot_root wrapper.
2025-07-01 02:16:17 -07:00
Aditya Ramani bdba5b5740 Create unpacker protocol + ext4 unpacker (#151)
Creates a new Unpacker protocol that defines a single method

```
func unpack(_ image: Image, for platform: Platform, at path: URL, progress: ProgressHandler?) async throws -> Mount
```

This change also removes the `unpack(...)` method from the Image type.

Before
```
let mount = try await image.unpack(for: platform, at: path)
```
After
```
let unpacker = EXT4Unpacker(blockSizeInBytes: 2.gib())
let mount = try await unpacker.unpack(image, for: platform, at: path)
```

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-30 11:06:38 -07:00
Danny Canter 631676b855 Remove preconcurrency from Virtualization import (#184)
I don't believe we need this for anything here (maybe we once did).
2025-06-30 12:39:12 -04:00
Dmitry Kovba 382c73ae78 Use a consistent capitalization in a bug report template (#181) 2025-06-27 15:51:47 -07:00
J Logan 1a59de82b0 Makes interface gateway configuration optional. (#156)
Here we implement the mechanism for ensuring that `container` doesn't
set up two default routes on containers that connect to multiple
networks. We'll implement the policy in apple/container#243.
2025-06-27 15:16:15 -04:00
Luis David Garcia 885db858a5 Updated documentation link in README (#161)
## Description of Change

- I updated the documentation link in the README: [Documentation
Tab](https://github.com/apple/containerization?tab=readme-ov-file#documentation)
- The original link (`open http://localhost:8000/documentation/`) was
returning a **404 error**, as shown in the screenshot below.
- I fixed the issue by updating the link to: `open
http://127.0.0.1:8000/containerization/documentation/`, which works
correctly.

## Screenshot of the 404 Error and the Fix

Here’s the screenshot showing the error and the fix:

![404 Error Shown and 200
Fix](https://github.com/user-attachments/assets/4198d381-80de-4bca-a9f4-5455eee887f6)
2025-06-27 15:14:33 -04:00
Kathryn Baldauf 73097b795c Remove use of triage label (#180)
Tags on the repo should be a way to classify an item instead of denoting
workflow or status of the item. Remove the addition of the triage label
on bug and feature issues.

Related to https://github.com/apple/container/pull/262

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-27 14:08:01 -04:00
Danny Canter c7763c76cf vmexec: Set perms on stdio (#174)
We don't chown the container's stdio today.
2025-06-27 11:03:21 -04:00
Danny Canter 059ff4033f Makefile: Revert recent reworking (#177)
Reverts f9198d6ff7

We can explore better approaches to some of the targets, but for now
lets revert as it interferes with being able to build even if we have
local changes.
2025-06-26 19:31:46 -04:00
Aditya Ramani 638bb96e3f Better error message for image pull failures (#175)
Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-26 15:47:35 -07:00
Danny Canter e274a79123 Pin Swift 6.2 version and Linux SDK (#178)
Until 6.2 officially releases lets pin to a static version of the 6.2
snapshots. The Linux SDK and swift version must be aligned so this
should be less fickle than using `6.2-snapshot` as this is a friendly
identifier to choose the latest uploaded snapshot.
2025-06-26 14:20:26 -07:00
Elijah Wright 538ea78c33 run cleanupRelay only once in TerminalIO and StandardIO (#153) 2025-06-26 12:03:17 -04:00
Kathryn Baldauf 958a83b23b Switch to using issue types for bugs and features (#170)
Matches https://github.com/apple/container/pull/258

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-25 17:09:53 -07:00
Mike Drob f9198d6ff7 Provides explicit makefile targets for files (#167)
fixes #165

`init` depends on `vminitd/bin/vminitd`, `vminitd/bin/vmexec`, and
`bin/cctl`
`integration` depends on `bin/containerization-integration`
`bin/*` get generated via `make containerization`
2025-06-25 13:53:35 -07:00
Danny Canter 5559dd5a3d VZVirtualMachineInstance: Rework installRosetta flow (#169)
Because we were installing rosetta directly in the constructor for
VZVirtualMachineInstance, and we'd prefer to not have the constructor
async as it pollutes so much more, we had devised this gnarly callback
approach for the install that is a bit of an eyesore. This changes focus
is on moving the install flow to a method that is already async so we
can piggyback off of it, and removing the install logic from the config
-> VZConfig conversion. Now the install will occur during start() if
rosetta is not installed.
2025-06-25 14:11:23 -04:00
Danny Canter 2dfabeb4f9 Vminitd: Rework ManagedContainer (#168)
This gets rid of some design decisions that I was not fond of. This
changes the process start for both execs and the init process to happen
internally in the object, as well as makes it so that all exec
functionalities can happen on the container object itself. This allows
us to get rid of the `if request.id == containerID` branches in the
rpcs, and handle this entirely in the object itself using its internal
state.

The existing integration tests should stress this just fine I believe.
2025-06-25 14:07:31 -04:00
Dmitry Kovba 4bacf4c578 Remove the support for CURRENT_SDK (#164)
This PR removes the no longer needed support for `CURRENT_SDK`.
2025-06-25 12:30:06 -04:00
Dmitry Kovba b626d32a48 Fix compilation warnings (#163)
This PR fixes compilation warnings observed in:
```
swift -v --version
Apple Swift version 6.2-dev (LLVM 5fbc818cf26c90b, Swift 2e1897356956e43)
Target: arm64-apple-macosx26.0
/Users/Dmitry/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-17-a.xctoolchain/usr/bin/swift-frontend --version
Apple Swift version 6.2-dev (LLVM 5fbc818cf26c90b, Swift 2e1897356956e43)
Target: arm64-apple-macosx26.0
Build config: +assertions
```
2025-06-24 13:15:44 -07:00
Dmitry Kovba ebcaf74f42 Regenerate documentation on make docs (#160)
This PR allows using `make docs` without manually removing the existing
`_site` folder.
2025-06-24 13:09:20 -07:00
Dmitry Kovba f2a2bd7fa5 Add a link to the container repository (#157)
This PR adds a link to the container repository on top of the
`README.md`:

<img width="877" alt="Screenshot 2025-06-20 at 7 54 46 PM"
src="https://github.com/user-attachments/assets/3aff3c13-b0ed-4bf6-b2c8-bb4e8ad64355"
/>
2025-06-24 12:48:28 -07:00
Dmitry Kovba 910992e4d8 Update Static Linux SDK to the latest version (#162)
Currently, when a user runs `make cross-prep`, we install the latest
version of Swift. This requires installing the latest version of Static
Linux SDK, which we should update as a new version is released.
2025-06-24 12:44:42 -07:00
Dmitry Kovba 5da0125228 Redirect to the documentation from the homepage (#159)
This PR fixes the homepage at https://apple.github.io/containerization/
2025-06-23 10:19:16 -07:00
Satyam Singh 22f2efd8d1 fix: correct release condition in GitHub Actions and globalize enviro… (#127)
# Refactor GitHub Actions Workflow: Containerization Build
## 🛠 Summary
This PR introduces several important improvements and cleanups to the
build-containerization-template GitHub Actions workflow for better
maintainability, correctness, and readability.

### 🔧 Changes Made
#### 1.  Fix invalid conditional syntax
- **!= is not supported in expressions** with **if**: in GitHub Actions.

- Only logical operators like !, &&, || are valid.

#### 2.  Globalized environment variables
- Moved CURRENT_SDK and DEVELOPER_DIR to the job-level env: block to:

- Avoid redundancy across steps

- Make the workflow more maintainable

### 3.  Replaced `secrets.GITHUB_TOKEN` with `github.token`
- Prefer github.token for GitHub-provided auth token to improve clarity
and scoping.

@katiewasnothere
2025-06-23 09:26:50 -07:00
Dmitry Kovba a339606068 Fix the Swiftly bin path (#158)
This PR resolves the following error for new users:

```
% make cross-prep
Installing Swiftly...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8549k  100 8549k    0     0  14.7M      0 --:--:-- --:--:-- --:--:-- 14.8M
installer: Package name is 
installer: Installing at base path /Users/Dmitry
installer: The install was successful.
Welcome to swiftly, the Swift toolchain manager for Linux and macOS!

Please read the following information carefully before proceeding with the installation. If you
wish to customize the steps performed during the installation process, refer to 'swiftly init -h'
for configuration options.

Swiftly installs files into the following locations:

/Users/Dmitry/.swiftly - Directory for configuration files
/Users/Dmitry/.swiftly/bin - Links to the binaries of the active toolchain
/Users/Dmitry/Library/Developer/Toolchains - Directory hosting installed toolchains

These locations can be changed by setting the environment variables
SWIFTLY_HOME_DIR, SWIFTLY_BIN_DIR, and SWIFTLY_TOOLCHAINS_DIR before running 'swiftly init' again.

For your convenience, swiftly will also attempt to modify your shell's profile file to make
installed items available in your environment upon login. This can be suppressed with the
'--no-modify-profile' option.

Proceed? (Y/n): 

Installing swiftly in /Users/Dmitry/.swiftly/bin/swiftly...
Error: The file “swiftly” couldn’t be opened because there is no such file.
make[1]: *** [swiftly] Error 1
make: *** [cross-prep] Error 2
```
2025-06-20 20:02:23 -07:00
Aditya Ramani 016c80fac0 Better parsing for www-authenticate headers (#155)
There was a bug where the `www-authenticate` header in the HTTP response
from a registry would not be parsed accurately.

Specifically, if the header value had more than one `<space>` character,
the entire header would be ignored. This PR fixes this bug and adds unit
test to detect this in the future.


Fixes https://github.com/apple/container/issues/240
And most likely fixes https://github.com/apple/container/issues/237

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-20 15:51:47 -07:00
Cornelius Roemer cad00de874 Fix typo in README (#54) 2025-06-18 17:31:58 -07:00
Danny Canter 2a96a0d447 Containerization: Always set TERM (#146)
Make sure we always set TERM for containers that ask for a tty. Right
now this handling was spread around in a bunch of spots, but I'd wager
setting it for the client on the host via LinuxContainer/Process is more
sane and already what we do for a lot of the other fields.
2025-06-18 17:00:00 -07:00
Danny Canter 1992cfe779 Containerization: Reduce allocations for image subsystems (#152)
Continue the allocations journey for anything that is in the codepaths
for pulling images. This time there's a couple spots in archive and ext4
we can get rid of some copies.
2025-06-18 16:11:46 -07:00
Nandha Reddy 35a821f041 fix: vminitd incorrectly overwrites custom HOME environment variable (#136)
## Summary

The vminitd service was using `process.env.contains("HOME")` which
checks for exact string match rather than environment variables starting
with "HOME=".

Since environment variables are stored as `"KEY=value"` strings, the
condition was always false, causing vminitd to always override custom
HOME values even when explicitly provided by the client.

## Changes

- Updates the logic in `vminitd/Sources/vminitd/Server+GRPC.swift` to
use `contains(where: { $0.hasPrefix("HOME=") })` to properly detect
existing HOME environment variables
- Adds regression test `testProcessCustomHomeEnvvar()` to verify that
custom HOME environment variables are preserved when provided by the
client

## Testing

The fix has been tested with the new integration test that:
  - Sets a custom HOME environment variable (`HOME=/tmp/custom/home`)
- Runs a shell command that outputs the HOME variable on the container
runtime
- Verifies the custom HOME value is preserved and not overwritten with
the default

## Environment

  - macOS: 26.0 (25A5279m)
  - Hardware: M4 Pro
  - Xcode: 26 beta
  - Swift: 6.2-dev

Fixes #135
2025-06-17 21:51:11 -07:00
Joseph Heck 445450dcce limits buildAndTest to Apple repository (#150)
Constrains the buildAndTest job to only run on the
`apple/containerization` repository due to Runner constraints.

Simplest solution - fixes #132
2025-06-17 14:20:20 -07:00
Alexey Makhov 689af841d6 Sort keys in image index to keep the digest consistent (#149)
The digest is calculated based on written json data, but JSONEncoder
doesn't preserve order bby default, so the digest is not consistent.

Signed-off-by: Alexey <makhov.alex@gmail.com>
2025-06-17 12:23:25 -07:00
Alexey Makhov 4a196b6dc2 Adds some context to fetchToken errors (#129)
Fixes https://github.com/apple/container/issues/182 and
https://github.com/apple/container/issues/183

Signed-off-by: Alexey <makhov.alex@gmail.com>
2025-06-17 08:26:46 -07:00
Riya Amemiya 4a482a00c0 Fix typos in README and LinuxContainer.swift comments (#144)
## Changes 

### README.md

- Fixed grammatical error: "when a process is ran" → "when a process is
run"
- Fixed plural form: "for instruction on" → "for instructions on"

### kernel/README.md

- Fixed numbering sequence: "4. Run `make`" → "3. Run `make`" in build
instructions

### Sources/Containerization/LinuxContainer.swift

- Fixed grammatical error in comment: "The container has ran" → "The
container has run"
2025-06-17 02:40:05 -07:00
Danny Canter 328221e44c ContainerizationOCI: Cut down on allocations (#141)
We were doing intermediate step copies to Data objects both for push and
pull. We only need the data for the lifetime of the singular writes to
update the state of the checksums and to write to disk somewhere, so we
can use a view into the buffer from the http client to satisfy this.
2025-06-16 22:18:36 -07:00
Danny Canter 5a360242d3 Fix make release goal (#140)
We were using a := assignment for BUILD_BIN_DIR which evaluates any
variables immediately. Our make release logic sets the envvar and then
invokes `all` but at that point the value of BUILD_BIN_DIR has already
been determined.
2025-06-16 17:40:25 -07:00
Dmitry Kovba b14395515c Fix warnings in make docs (#139)
This PR also has additional small improvements.
2025-06-16 17:22:22 -07:00
Josh Soref c00ede68c1 fix comment misspellings (#131)
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/containerization/actions/runs/15662940240/attempts/1#summary-44123291170
The action reports that the changes in this PR would make it happy:
https://github.com/jsoref/containerization/actions/runs/15662940315/attempts/1#summary-44123291367

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2025-06-16 16:06:37 -04:00
Aditya Ramani f4177e7d67 More informative errors from RegistryClient (#134)
Also creates an `ErrorResponse` type to model the errors typically
returned by a container registry.

Reference: https://distribution.github.io/distribution/spec/api/#errors

Example error message:
```
Error: HTTP request to https://ghcr.io/token?client_id=containerization-registry-client&service=ghcr.io&scope=repository:user/image:pull failed with response: 403 Forbidden. Reason: {"errors":[{"message":"requested access to the resource is denied","code":"DENIED"}]}
```

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-16 11:07:32 -07:00
Danny Canter 77c54434b8 LinuxProcess: Always return CZError (#111)
We should return our own error type always for our methods. This wraps
all of the public methods on the process to return a more full featured
error than the rpcerrors we get today.
2025-06-16 13:40:36 -04:00
Dmitry Kovba a65deb517a Add instructions for installing Xcode (#125)
Now, we require installing Xcode 26 beta. This PRs adds an important
step of setting the active developer directory. Fixes
https://github.com/apple/containerization/issues/119.
2025-06-16 09:23:34 -07:00
Danny Canter 3cf8eeebf4 SandboxContext: Remove AttachProcessRequest/Response (#121)
These were not used in any rpcs and were a leftover idea.
2025-06-13 21:56:54 -07:00
Danny Canter 8923495949 Vminitd: Remove unneeded mkdir (#123)
The rootfs should be mounted by this point in oci alteration code.
2025-06-13 21:56:25 -07:00
Dmitry Kovba a3cb1f0103 Update to Swift 6.2 and Swift 6.2-snapshot in vminitd (#94)
This PR resolves https://github.com/apple/containerization/issues/58 and
https://github.com/apple/containerization/issues/119. Requires updating
Swift and Static Linux SDK on GitHub runners. Please also see
https://github.com/apple/container/pull/195.
2025-06-13 17:46:30 -07:00
Kathryn Baldauf 4751d073bb Improve release tag regex (#122)
Matches changes made in https://github.com/apple/container/pull/187 by
@Thedarkmatter10

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-13 14:45:16 -07:00
Seyed Mojtaba Hosseini Zeidabadi 763141633c build: extend the swift-syntax version range (#97)
Building Swift-Syntax can be time-consuming, but this issue has been
resolved in the latest version by using a prebuilt binary. This
improvement enhances CI build times and the overall quality of the
package.

I’ve kept the version at 600 for compatibility reasons, but it might be
possible to start from 601 as well.
Please let me know.
Thanks
2025-06-13 11:20:50 -07:00
Kathryn Baldauf 4300595d03 Add fallback year or hawkeye formatting if no git attributes (#120)
Matches https://github.com/apple/container/pull/180

This adds a default year to use when a file does not yet have git
attributes (aka for a newly created file).

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-06-13 09:55:37 -07:00
Dmitry Kovba 256daaf481 Update issue templates (#114)
Please see commits for the list of changes.
2025-06-13 09:10:43 -07:00
Aditya Ramani a4a0cdfae1 Add a way to detect if a process' io has completed (#110)
This change adds a new private method `waitIoComplete` on the
`LinuxProcess` type.

This method is called internally when the user calls `wait` for a
process - and it tries to give the IO streams some time to clear their
buffers.

Internally, this method sets up an `AsyncStream` down which an item is
sent when the vsock connection for either stdout/stderr is terminated.
We get this termination signal when the readability handler for the
associated fd fires with a no available data.

Inside the guest - once we are done relaying the IO from the process
into the socket connection, we close the socket fd which triggers the
above.

All this logic is wrapped around a timeout of 3 seconds, just to ensure
the method does not block forever.

---------

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2025-06-13 11:23:41 -04:00
Danny Canter a56fdb7046 LinuxContainer: Remove extraneous extensions (#117)
Not sure why we had this type in 12 different sections 😅.
2025-06-13 10:14:19 -04:00