191 Commits

Author SHA1 Message Date
J Logan a8c779fd65 Uniform support for --platform, --os, --arch. (#545)
- Fixes #231.
- Extends #313 (@dcantah) so that all of `container create`, `container
run`, `container build`, `container image pull`, and `container image
save` accept the three options.
- `container build` now processes comma-separated lists for
`--platform`, `--arch`, and `--os`. It first checks `--platform`,
assembling the union of all platform values. If that set is non-empty,
the builder builds the values in the set. Otherwise, the set consists of
all combinations of the specified architecture and os values, finally
defaulting to `linux` and the host architecture if no options are
provided.
- All other commands work accept a single platform, preferring the
`--platform` option over `--arch` and `--os` when both are specified.
`--os` defaults to `linux`, and `--arch` defaults to the host
architecture.
- Clarify help messages and present the args in consistent order, with
platform first since it takes precedence if present.
- Deduplicate redundant platform options for `container build`.
0.4.0
2025-08-27 13:26:01 -07:00
Danny Canter df1cc1b184 Revert "Integration: Log container bootlog in run test failures (#541)" (#548)
This reverts commit 41add29673.

We've discovered a quite fun issue with some of our rpcs (stop+delete)
in sequence when done fast enough. It needs a bit of reworking to get
into shape. While the work here is very useful, we can add this back
after the rpc ordering is solved.
2025-08-27 12:32:26 -07:00
Danny Canter c2d6ffc89a CLI: Send logs to stderr (#544)
I'm not sure why we had these going to OSLog, but I'd wager they're a
bit more useful being displayed directly to the user during the command
they're running.
2025-08-26 17:33:47 -07:00
Danny Canter c65e892243 ContainerService: Remove lock from list() (#537) 2025-08-26 16:23:35 -07:00
Danny Canter 23c526233d ContainerService: Move force delete logic to daemon (#536)
Today force deleting (if a container is running then stop()'ing first)
is handled entirely in the cli, which is brittle. The CLI doesn't know
if the container was started with --rm so it would have to do a weird
timeout + list dance to check if the containers gone after stopping.
This change remedies this by just having the daemon take in a `force`
boolean to the delete rpc. If this is provided and the container is
running then we'll stop first, and then cleanup. We can additionally not
cleanup if --rm was provided as the daemon has the data to determine if
a container asked for autoRemove.
2025-08-26 14:23:39 -07:00
Danny Canter 41add29673 Integration: Log container bootlog in run test failures (#541)
If any of the container run tests fail on the basic setup phases (e.g.
actually starting the container) we should log the bootlog to see if we
can glean any info off of this.
2025-08-26 13:37:04 -07:00
Danny Canter b50dc253e9 Bump CZ to 0.6.2 (#543)
Hopefully fixes CI..
2025-08-26 10:39:07 -07:00
Danny Canter 7f7090ff87 Bump CZ to 0.6.1 (#540)
This has one change since 0.6.0 that just adds a log in the guest to see
the spec for any execed processes.
2025-08-25 13:38:21 -07:00
Dmitry Kovba 0fd7005119 Fix a warning when testing (#531)
Fixes a warning missed in https://github.com/apple/container/pull/516.
2025-08-21 10:08:27 -07:00
J Logan 879dff8fcf Allow traversing symlink when checking for builtin plugins. (#528)
- This helps with brew cask packaging, can postflight link
libexec/container/plugins to the appropriate cask location, and the
plugin discovery will traverse the link.
2025-08-20 23:52:24 -07:00
Dmitry Kovba 9a597eb6aa Add the support for ARG in the native builder parser (#516)
This PR adds the support for the ARG instruction in the native builder
parser, implements the support for different kinds of ARGs, and performs
the substitution of ARG variables in the supported instructions.
Resolves https://github.com/apple/container/issues/437.

Some features are currently blocked and not included into this PR:
- [Native builder: add the current target platform we're building use it
to set automatic platform ARGs
#522](https://github.com/apple/container/issues/522)
- [Native builder: add the support for the BuildKit built-in ARGs
#523](https://github.com/apple/container/issues/523)
- [Native builder: ensure pre-defined ARGs are excluded from the output
of the history #524](https://github.com/apple/container/issues/524)
- [Native builder: add the support for stage references and ARG
inheritance #525](https://github.com/apple/container/issues/525)
2025-08-20 14:57:24 -07:00
J Logan 6767144d43 Bump containerization dependency to 0.6.0 (#526) 2025-08-19 18:58:09 -07:00
J Logan 07679d99c7 Extract version output logic so --version is consistent. (#517) 2025-08-18 10:27:27 -07:00
Jacob Ford fe72d7ba41 Docs: clarify Xcode 26 beta must be the active developer directory (#238)
And add instructions for setting it so

Related: https://github.com/apple/containerization/issues/66
2025-08-18 12:11:54 -04:00
Renee Chang 3349a90ba7 Fix SSH forwarding for exec process (#506)
This PR fixes SSH forwarding for exec processes.

Currently, only init processes received the `SSH_AUTH_SOCK` environment
variable when using `--ssh` flag. Exec processes didn't have access to
the SSH agent socket, even though the socket was mounted.

Now we set environment variable for exec processes to match init process
behavior, ensuring SSH forwarding works consistently across processes,
and refactoring SSH forwarding condition into `hostSocketUrl()` helper
function.
2025-08-15 17:54:09 -07:00
J Logan e616143b95 Adds container builder rm alias. (#505) 2025-08-15 16:55:21 -07:00
J Logan 049adc96ea Adds how-to section for --ssh. (#503) 2025-08-15 15:37:58 -07:00
Renee Chang 94778981c8 Add SSH auth socket forwarding (#502)
Add `--ssh` flag to forward the host's SSH agent socket into the
container, so we can use SSH authentication for things like cloning
private repos, and also updates the socket path every time the container
starts to handle socket path changes like reboot/re-login.

Closes #498
2025-08-15 11:54:56 -07:00
J Logan a8dbf294f6 Ensure two containers cannot use the same DNS hostname. (#490)
- Closes #150, #394.
- Introduces `AttachmentConfiguration` type so that we can add key-value
options to `--network` in the future.
- Eliminates redundant `ContainersService.Item` type.
- Since we now ensure at ContainersService that hostnames will not
conflict, the network helper IP allocator now simply provides the
existing IP if for an allocation on an existing hostname, which should
handle (in an eventually consistent way) the case where a container
fails to deallocate an IP on shutdown.
2025-08-13 18:18:19 -07:00
Dmitry Kovba d2eb350393 Preserve permissions by default and fix warnings (#496)
Permissions should be preserved when copying by default. This PR also
fixes other warnings while building and testing.
2025-08-13 16:50:19 -07:00
J Logan b9a6bf52cc Fixes builder compiler errors and warnings. (#495) 2025-08-13 13:25:41 -07:00
Renee Chang 8db69e83b1 Make Parser functions public for CLI plugins (#494)
This PR makes `Parser` functions public to allow CLI plugins to access
for consistent argument parsing.
2025-08-13 13:20:34 -07:00
Danny Canter 66426acfbb CLI: Defer tty reset immediately (#488)
We were defer closing the IO for run/exec/start fairly late in the
container run cycle which had the downside of that if the container run
failed your tty would be stuck in raw mode. This change just moves the
closing (return tty to origin state) to directly after we create the IO.
2025-08-13 15:04:18 -04:00
Sidhartha Mani 3d0c1fee97 Native Builder: Build Cache to use new snapshotter (#492) 2025-08-13 10:46:14 -07:00
Sidhartha Mani d2f48982c1 Native Builder: Define Snapshotter protocol (#491)
This PR defines the snapshotter protocol

```swift
    ///Mount a snapshot and all its previous layers
    func prepare(_ snapshot: Snapshot) async throws -> Snapshot

    /// Commit a snapshot, making it permanent.
    func commit(_ snapshot: Snapshot) async throws -> Snapshot

    /// Remove a snapshot from snapshot store
    func remove(_ snapshot: Snapshot) async throws
```

It updates executors to work with this new protocol
2025-08-12 23:30:56 -07:00
Sidhartha Mani 0885cdd6a9 Native Builder: DiffKey and Differ Procol (#482)
This PR introduces the `Differ` with methods:

```swift
// Differ protocol
func diff(base: Snapshot?, target: Snapshot) async throws -> Descriptor
func apply(descriptor: Descriptor, to base: Snapshot?) async throws -> Snapshot
```

It also introduces `DiffKey`, which is a MerkeTree based key for fast
diff computations between two dirs
2025-08-12 11:23:55 -07:00
Danny Canter adf7186d54 CLI (run): Only ask for stdin for -i (#483)
Today if you asked for a pty and also wanted to detach we'd open stdin
and then immediately close that pipe which would close the guest relay
as well. I don't believe we need stdin open unless it's asked for with
-i. Truthfully there's one extra bit here that is needed which is if -i
and -d are supplied we need to tell the daemon to open stdin, but not
send an fd (as they're client supplied and the client/cli is going to
exit immediately). That will need to be a followup, as it's mainly
useful for attach which we don't have today.
2025-08-11 23:53:53 -04:00
Tim Sneath 71ee41f7be Clarify macOS version support and minor style tweaks (#485)
Clarify that container is only supported on macOS 26, and remove
language that implies that it's also designed for macOS 15.

This change also includes a couple of minor Apple Style Guide changes,
and links to the OCI container image format for clarity.
2025-08-11 13:35:34 -07:00
J Logan 6242706c66 Fixes for install root and plugin detection. (#467)
- Sets up API server as source of truth for installation root, similarly
to what was done for the data root. `system start` establishes the
install root, setting the environment variable `CONTAINER_INSTALL_ROOT`
when launching the API server.
- The API server propagates the environment variable when launching
helpers, and returns the install root to the CLI via the health check
XPC.
- Includes several fixes for detecting plugins that use app bundle
layout.
2025-08-08 21:44:26 -07:00
J Logan d242864e9f Relocate and rename ClientDefaults. (#474)
- Part of #384.
- Rename to reflect that these are not just client defaults.
- Relocate so callers don't need the heavyweight coupling to
ContainerClient to access the type.
2025-08-08 16:04:32 -07:00
J Logan edad7dd0df Prevent removal of network with container references. (#470)
- Closes #392.
2025-08-08 13:25:26 -07:00
Kathryn Baldauf c21068661f Native builder parser support for EXPOSE (#465)
Closes https://github.com/apple/container/issues/430

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-08-07 12:17:59 -07:00
J Logan 88223d8add Select alternate data path with container system start --app-root path. (#419)
Closes #418.
2025-08-06 14:49:09 -07:00
Raj b8965cae43 Named Volumes (#362)
Closes #339.

This change adds named volume support to container, providing volume
management CLI commands - `create, delete, list and inspect`. The
implementation uses EXT4 block-based persistent storage with a new
`VolumesService` actor for thread-safe operations, integrates seamlessly
with the existing container mount system through a new `.volume`
filesystem type, and provides atomic volume operations with XPC-based
API communication. Volumes are stored in isolated directories with
configurable sizes (default 512GB) and include proper cleanup and
container usage tracking for safe deletion.

Example Usage:

```
# Create a volume
container volume create mydata

# Use volume in container
container run -v mydata:/data alpine

# List volumes
container volume list

# Inspect volume details
container volume inspect mydata

# Clean up
container volume rm mydata
```
2025-08-05 21:47:42 -07:00
Kathryn Baldauf d048ea5201 Native builder: remove option token in favor of string literals (#450)
Remove the option token from the dockerfile tokenizer for the native
builder. This cleans up some of the logic around handling options
depending on if they're instruction options or user provided options to
a command.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-08-05 16:33:07 -07:00
Kathryn Baldauf 8adb215522 Native Builder: Add parser support for CMD and LABEL instructions (#448)
This PR adds support for CMD and LABEL instructions in the native
builder's parser.

This also changes how options are tokenized. Options now include the raw
string so that when constructing a command for instructions like CMD and
RUN, we can use the exact user input without having to add logic in the
tokenizer to know when we're parsing a command verses other options,
etc.

Closes https://github.com/apple/container/issues/428 and
https://github.com/apple/container/issues/429

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-08-05 14:34:34 -07:00
Danny Canter f2130a9604 Generate /etc/hosts by default (#423)
Closes: #314

This change uses the new `.hosts` config entry
on Containerization's LinuxContainer config to setup a default
/etc/hosts file in the container. Today the two entries are localhost to
127.0.0.1 and the container's IP to its hostname.
2025-08-05 12:44:13 -07:00
Dmitry Kovba e7da2d59f1 Do not print task descriptions with disabled progress updates (#444)
Fully resolves https://github.com/apple/container/issues/396.
2025-08-05 12:29:26 -07:00
YR Chen ce431b5c8f Optionally resolve wrapper index to single-platform manifest based on com.apple.containerization.index.indirect annotation (#397)
Fixes #212

This PR:
- adds a `package func resolved()` on `ClientImage` that makes use of
the new `com.apple.containerization.index.indirect` annotation to
identify and resolve wrapper indices created by Containerization;
- replace the digest displayed in `container image list` with the one of
the resolved manifest;
- use the resolved manifest for `container image inspect` if the index
is a wrapper.
2025-08-04 11:14:00 -07:00
Dmitry Kovba 9e9d056339 Transition to Mutex (#364)
Due to the reduced use of the macro, we can now fully transition to
`Mutex`.
2025-07-31 13:36:18 -07:00
Kathryn Baldauf 16f2630126 Add initial native builder code (#399)
We're working on making a pure swift container image build system that
leverages containerization. This PR represents our initial design and
initial work towards this goal.

The native builder is still in active development and most of the
implementation has not been started or completed. We will be opening a
series of issues that represent various (but not necessarily all) pieces
of work that need to be done here.

There are docs included in this PR that describe the overall design of
each component and outline some of our goals. The easiest way to view
the docs by themselves (since this is a massive PR) is to look at the
docs commit in the `Commits` tab.

We'd love any feedback! 

@wlan0

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-07-31 13:13:20 -07:00
Danny Canter 3fcf647c7b Add virtualization support for containers (#377) 0.3.0 2025-07-30 11:14:41 -07:00
Justin Yao Du 728527b8ba Explain how to install a release build in BUILDING.md (#379)
When users run commands with a debug build, they see a warning that
debug builds may have worse performance. Add instructions to BUILDING.md
so that users who wish to install from source know how to get a release
build.

I tested the command locally and ran `container --version` to verify
that I got a release build.
2025-07-29 19:11:06 -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
Sam Lord 837ef61397 Clarified documentation (#388)
The demonstration is that patch versions can be updated without breaking
changes, and that minor versions include breaking changes.

Please excuse the small documentation commit, just caused me a moment of
confusion.
2025-07-28 15:11:08 -07:00
Kathryn Baldauf 7dc1dda43f Update xcode developer version to new symlink (#374)
Related to https://github.com/apple/containerization/pull/234

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-07-25 13:11:29 -07: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